Class ObjectIterators.AbstractIndexBasedListIterator<K>
- All Implemented Interfaces:
BidirectionalIterator<K>,ObjectBidirectionalIterator<K>,ObjectIterator<K>,ObjectListIterator<K>,java.util.Iterator<K>,java.util.ListIterator<K>
- Enclosing class:
- ObjectIterators
public abstract static class ObjectIterators.AbstractIndexBasedListIterator<K> extends ObjectIterators.AbstractIndexBasedIterator<K> implements ObjectListIterator<K>
This class is only appropriate for sequences that are at most
Integer.MAX_VALUE long. If your backing data store can be bigger then
this, consider the equivalently named class in the type specific
BigListSpliterators class.
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 voidadd(K k)Inserts the specified element into the list (optional operation).intback(int n)Moves back for the given number of elements.booleanhasPrevious()Returns whether there is a previous element.intnextIndex()Kprevious()Returns the previous element from the collection.intpreviousIndex()voidset(K k)Replaces the last element returned byIterator.next()orBidirectionalIterator.previous()with the specified element (optional operation).Methods inherited from class it.unimi.dsi.fastutil.objects.ObjectIterators.AbstractIndexBasedIterator
forEachRemaining, hasNext, next, remove, skipMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemainingMethods inherited from interface java.util.ListIterator
hasNext, nextMethods inherited from interface it.unimi.dsi.fastutil.objects.ObjectBidirectionalIterator
skipMethods inherited from interface it.unimi.dsi.fastutil.objects.ObjectListIterator
remove
-
Method Details
-
hasPrevious
public boolean hasPrevious()Description copied from interface:BidirectionalIteratorReturns whether there is a previous element.- Specified by:
hasPreviousin interfaceBidirectionalIterator<K>- Specified by:
hasPreviousin interfacejava.util.ListIterator<K>- Returns:
- whether there is a previous element.
- See Also:
ListIterator.hasPrevious()
-
previous
Description copied from interface:BidirectionalIteratorReturns the previous element from the collection.- Specified by:
previousin interfaceBidirectionalIterator<K>- Specified by:
previousin interfacejava.util.ListIterator<K>- Returns:
- the previous element from the collection.
- See Also:
ListIterator.previous()
-
nextIndex
public int nextIndex()- Specified by:
nextIndexin interfacejava.util.ListIterator<K>
-
previousIndex
public int previousIndex()- Specified by:
previousIndexin interfacejava.util.ListIterator<K>
-
add
Description copied from interface:ObjectListIteratorInserts the specified element into the list (optional operation).This default implementation just throws an
UnsupportedOperationException.- Specified by:
addin interfacejava.util.ListIterator<K>- Specified by:
addin interfaceObjectListIterator<K>- Parameters:
k- the element to insert.- See Also:
ListIterator.add(Object)
-
set
Description copied from interface:ObjectListIteratorReplaces the last element returned byIterator.next()orBidirectionalIterator.previous()with the specified element (optional operation).- Specified by:
setin interfacejava.util.ListIterator<K>- Specified by:
setin interfaceObjectListIterator<K>- Parameters:
k- the element used to replace the last element returned.This default implementation just throws an
UnsupportedOperationException.- See Also:
ListIterator.set(Object)
-
back
public int back(int n)Description copied from interface:ObjectBidirectionalIteratorMoves back for the given number of elements.The effect of this call is exactly the same as that of calling
BidirectionalIterator.previous()forntimes (possibly stopping ifBidirectionalIterator.hasPrevious()becomes false).- Specified by:
backin interfaceObjectBidirectionalIterator<K>- Parameters:
n- the number of elements to skip back.- Returns:
- the number of elements actually skipped.
- See Also:
BidirectionalIterator.previous()
-