Class IntSet.IntSetIterator
java.lang.Object
com.github.tommyettinger.ds.IntSet.IntSetIterator
- All Implemented Interfaces:
IntIterator, Iterator<Integer>
- Direct Known Subclasses:
IntOrderedSet.IntOrderedSetIterator
- Enclosing class:
IntSet
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intThe current index in the set's key table; this is the index that will be removed ifremove()is called.booleanThis can be queried in place of callinghasNext().protected intThe next index in the set's key table to go to and return fromnextInt()(or, while discouraged because of boxing,IntIterator.next()).protected final IntSetThe set to iterate over. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAppend the remaining items that this can iterate through into the given PrimitiveCollection.OfInt.protected voidbooleanhasNext()Returnstrueif the iteration has more elements.intnextInt()Returns the nextintelement in the iteration.voidremove()voidreset()toList()Returns a newIntListcontaining the remaining items.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface IntIterator
forEachRemaining, nextMethods inherited from interface Iterator
forEachRemaining
-
Field Details
-
hasNext
public boolean hasNextThis can be queried in place of callinghasNext(). The method also performs a check that the iterator is valid, where using the field does not check. -
nextIndex
protected int nextIndexThe next index in the set's key table to go to and return fromnextInt()(or, while discouraged because of boxing,IntIterator.next()). -
currentIndex
protected int currentIndexThe current index in the set's key table; this is the index that will be removed ifremove()is called. -
set
The set to iterate over.
-
-
Constructor Details
-
IntSetIterator
-
-
Method Details
-
reset
public void reset() -
findNextIndex
protected void findNextIndex() -
hasNext
public boolean hasNext()Returnstrueif the iteration has more elements. (In other words, returnstrueifIntIterator.next()would return an element rather than throwing an exception.) -
remove
-
nextInt
public int nextInt()Description copied from interface:IntIteratorReturns the nextintelement in the iteration.- Specified by:
nextIntin interfaceIntIterator- Returns:
- the next
intelement in the iteration
-
toList
-
appendInto
Append the remaining items that this can iterate through into the given PrimitiveCollection.OfInt. Does not change the position of this iterator.- Parameters:
coll- any modifiable PrimitiveCollection.OfInt; may have items appended into it- Returns:
- the given primitive collection
-