Class ObjectBigListIterators.AbstractIndexBasedBigListIterator<K>

java.lang.Object
it.unimi.dsi.fastutil.objects.AbstractObjectIterator<K>
it.unimi.dsi.fastutil.objects.ObjectBigListIterators.AbstractIndexBasedBigIterator<K>
it.unimi.dsi.fastutil.objects.ObjectBigListIterators.AbstractIndexBasedBigListIterator<K>
All Implemented Interfaces:
BidirectionalIterator<K>, BigListIterator<K>, ObjectBidirectionalIterator<K>, ObjectBigListIterator<K>, ObjectIterator<K>, java.util.Iterator<K>
Enclosing class:
ObjectBigListIterators

public abstract static class ObjectBigListIterators.AbstractIndexBasedBigListIterator<K>
extends ObjectBigListIterators.AbstractIndexBasedBigIterator<K>
implements ObjectBigListIterator<K>
A skeletal implementation for a list-iterator backed by an index based data store. High performance concrete implementations (like the main ListIterator of ArrayList) generally should avoid using this and just implement the interface directly, but should be decent for less performance critical implementations.

As the abstract methods in this class are used in inner loops, it is generally a good idea to override the class as final as to encourage the JVM to inline them (or alternatively, override the abstract methods as final).

  • Method Summary

    Modifier and Type Method Description
    void add​(K k)
    Inserts the specified element into the list (optional operation).
    long back​(long n)
    Moves back for the given number of elements.
    boolean hasPrevious()
    Returns whether there is a previous element.
    long nextIndex()
    Returns the index of the element that would be returned by a subsequent call to next.
    K previous()
    Returns the previous element from the collection.
    long previousIndex()
    Returns the index of the element that would be returned by a subsequent call to previous.
    void set​(K k)
    Replaces the last element returned by next() or previous() with the specified element (optional operation).

    Methods inherited from class it.unimi.dsi.fastutil.objects.ObjectBigListIterators.AbstractIndexBasedBigIterator

    forEachRemaining, hasNext, next, remove, skip, skip

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.Iterator

    forEachRemaining, hasNext, next, remove

    Methods inherited from interface it.unimi.dsi.fastutil.objects.ObjectBidirectionalIterator

    back

    Methods inherited from interface it.unimi.dsi.fastutil.objects.ObjectBigListIterator

    skip, skip
  • Method Details

    • hasPrevious

      public boolean hasPrevious()
      Description copied from interface: BidirectionalIterator
      Returns whether there is a previous element.
      Specified by:
      hasPrevious in interface BidirectionalIterator<K>
      Returns:
      whether there is a previous element.
      See Also:
      ListIterator.hasPrevious()
    • previous

      public K previous()
      Description copied from interface: BidirectionalIterator
      Returns the previous element from the collection.
      Specified by:
      previous in interface BidirectionalIterator<K>
      Returns:
      the previous element from the collection.
      See Also:
      ListIterator.previous()
    • nextIndex

      public long nextIndex()
      Description copied from interface: BigListIterator
      Returns the index of the element that would be returned by a subsequent call to next. (Returns list size if the list iterator is at the end of the list.)
      Specified by:
      nextIndex in interface BigListIterator<K>
      Returns:
      the index of the element that would be returned by a subsequent call to next, or list size if list iterator is at end of list.
      See Also:
      ListIterator.nextIndex()
    • previousIndex

      public long previousIndex()
      Description copied from interface: BigListIterator
      Returns the index of the element that would be returned by a subsequent call to previous. (Returns -1 if the list iterator is at the beginning of the list.)
      Specified by:
      previousIndex in interface BigListIterator<K>
      Returns:
      the index of the element that would be returned by a subsequent call to previous, or -1 if list iterator is at beginning of list.
      See Also:
      ListIterator.previousIndex()
    • add

      public void add​(K k)
      Description copied from interface: ObjectBigListIterator
      Inserts the specified element into the list (optional operation).
      Specified by:
      add in interface BigListIterator<K>
      Specified by:
      add in interface ObjectBigListIterator<K>
      Parameters:
      k - an element.
      See Also:
      ListIterator.add(Object)
    • set

      public void set​(K k)
      Description copied from interface: ObjectBigListIterator
      Replaces the last element returned by next() or previous() with the specified element (optional operation).
      Specified by:
      set in interface BigListIterator<K>
      Specified by:
      set in interface ObjectBigListIterator<K>
      Parameters:
      k - an element.
      See Also:
      ListIterator.set(Object)
    • back

      public long back​(long n)
      Description copied from interface: ObjectBigListIterator
      Moves back for the given number of elements.

      The effect of this call is exactly the same as that of calling previous() for n times (possibly stopping if BidirectionalIterator.hasPrevious() becomes false).

      Specified by:
      back in interface ObjectBigListIterator<K>
      Parameters:
      n - the number of elements to skip back.
      Returns:
      the number of elements actually skipped.
      See Also:
      BidirectionalIterator.previous()