Class ObjectBigListIterators.AbstractIndexBasedBigIterator<K>
- All Implemented Interfaces:
it.unimi.dsi.fastutil.objects.ObjectIterator<K>,Iterator<K>
- Direct Known Subclasses:
ObjectBigListIterators.AbstractIndexBasedBigListIterator
- Enclosing class:
ObjectBigListIterators
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).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longThe last returned index by a call tonext()or, if a list-iterator,Isinvalid @link
{@link java.util.ListIterator#previous().-1if no such call has occurred or a mutation has occurred through this iterator and no advancement has been done.protected final longThe minimum pos can be, and is the logical start of the "range".protected longThe current position index, the index of the item to be returned after the next call tonext(). -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractIndexBasedBigIterator(long minPos, long initialPos) -
Method Summary
Modifier and TypeMethodDescriptionvoidforEachRemaining(Consumer<? super K> action) protected abstract Kget(long location) Get the item corresponding to the given index location.protected abstract longThe maximum pos can be, and is the logical end of the "range".booleanhasNext()next()voidremove()protected abstract voidremove(long location) Remove the item at the given index.intskip(int n) longskip(long n)
-
Field Details
-
minPos
protected final long minPosThe minimum pos can be, and is the logical start of the "range". Usually set to the initialPos unless it is a ListIterator, in which case it can vary. There isn't any way for a range to shift its beginning like the end can (throughremove(long)), so this is final. -
pos
protected long posThe current position index, the index of the item to be returned after the next call tonext().This value will be between
minPosandgetMaxPos()(exclusive) (on a best effort, so concurrent structural modifications outside this iterator may cause this to be violated, but that usually invalidates iterators anyways). ThusposbeingminPos + 2would meannext()was called twice and the next call will return the third element of this iterator. -
lastReturned
protected long lastReturnedThe last returned index by a call tonext()or, if a list-iterator,Isinvalid @link
{@link java.util.ListIterator#previous().-1if no such call has occurred or a mutation has occurred through this iterator and no advancement has been done.
-
-
Constructor Details
-
AbstractIndexBasedBigIterator
protected AbstractIndexBasedBigIterator(long minPos, long initialPos)
-
-
Method Details
-
get
Get the item corresponding to the given index location.Do not advance
posin this method; the defaultnextmethod takes care of this.The
locationgiven will be betweenminPosandgetMaxPos()(exclusive). Thus, alocationofminPos + 2would meannext()was called twice and this method should return what the next call tonext()should return. -
remove
protected abstract void remove(long location) Remove the item at the given index.Do not modify
posin this method; the default#remove()method takes care of this.This method should also do what is needed to track the change to the
getMaxPos(). Usually this is accomplished by having this method call the parent's appropriate remove method, and havinginvalid reference
CollectiongetMaxPos()track the parent collection'ssize64(). -
getMaxPos
protected abstract long getMaxPos()The maximum pos can be, and is the logical end of the "range".If pos is equal to the return of this method, this means the last element has been returned and the next call to
next()will throw.Usually set return the parent collection's
size64(), but does not have to be (for example, sublists and subranges). -
hasNext
public boolean hasNext() -
next
-
remove
public void remove() -
forEachRemaining
-
skip
public long skip(long n) -
skip
public int skip(int n)
-