Class CharIterators.AbstractIndexBasedIterator
- All Implemented Interfaces:
it.unimi.dsi.fastutil.chars.CharIterator,Iterator<Character>,PrimitiveIterator<Character,it.unimi.dsi.fastutil.chars.CharConsumer>
- Direct Known Subclasses:
CharIterators.AbstractIndexBasedListIterator
- Enclosing class:
CharIterators
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 BigListIterators 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).
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.PrimitiveIterator
PrimitiveIterator.OfDouble, PrimitiveIterator.OfInt, PrimitiveIterator.OfLong -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intThe last returned index by a call toCharIterator.next()or, if a list-iterator,It is −1 if no such call has occurred or a mutation has occurred through this iterator and no advancement has been done.invalid @link
{@link java.util.ListIterator#previous().protected final intThe minimum pos can be, and is the logical start of the "range".protected intThe current position index, the index of the item to be returned after the next call toCharIterator.next(). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidforEachRemaining(it.unimi.dsi.fastutil.chars.CharConsumer action) protected abstract charget(int location) Get the item corresponding to the given index location.protected abstract intThe maximum pos can be, and is the logical end (exclusive) of the "range".booleanhasNext()charnextChar()voidremove()protected abstract voidremove(int location) Remove the item at the given index.intskip(int n) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface it.unimi.dsi.fastutil.chars.CharIterator
forEachRemaining, forEachRemaining, next
-
Field Details
-
minPos
protected final int 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(int)), so this is final. -
pos
protected int posThe current position index, the index of the item to be returned after the next call toCharIterator.next().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 meanCharIterator.next()was called twice and the next call will return the third element of this iterator. -
lastReturned
protected int lastReturnedThe last returned index by a call toCharIterator.next()or, if a list-iterator,It is −1 if no such call has occurred or a mutation has occurred through this iterator and no advancement has been done.invalid @link
{@link java.util.ListIterator#previous().
-
-
Constructor Details
-
AbstractIndexBasedIterator
protected AbstractIndexBasedIterator(int minPos, int initialPos)
-
-
Method Details
-
get
protected abstract char get(int location) 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 meanCharIterator.next()was called twice and this method should return what the next call toCharIterator.next()should return. -
remove
protected abstract void remove(int 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.invalid reference
collection's size
-
getMaxPos
protected abstract int getMaxPos()The maximum pos can be, and is the logical end (exclusive) 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
CharIterator.next()will throw.Usually set return the parent
, but does not have to be (for example, sublists and subranges).invalid reference
collection's size
-
hasNext
public boolean hasNext() -
nextChar
public char nextChar() -
remove
public void remove() -
forEachRemaining
public void forEachRemaining(it.unimi.dsi.fastutil.chars.CharConsumer action) -
skip
public int skip(int n)
-