Package com.github.tommyettinger.ds
Class LongSet.LongSetIterator
java.lang.Object
com.github.tommyettinger.ds.LongSet.LongSetIterator
- All Implemented Interfaces:
LongIterator,Iterator<Long>
- Direct Known Subclasses:
LongOrderedSet.LongOrderedSetIterator
- Enclosing class:
- LongSet
-
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 fromnextLong()(or, while discouraged because of boxing,LongIterator.next()).protected final LongSetThe set to iterate over.protected booleanInternally employed by the iterator-reuse functionality. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAppend the remaining items that this can iterate through into the given PrimitiveCollection.OfLong.protected voidbooleanhasNext()Returnstrueif the iteration has more elements.longnextLong()Returns the nextlongelement in the iteration.voidremove()voidreset()toList()Returns a newLongListcontaining the remaining items.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemainingMethods inherited from interface com.github.tommyettinger.ds.support.util.LongIterator
forEachRemaining, next
-
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 fromnextLong()(or, while discouraged because of boxing,LongIterator.next()). -
currentIndex
protected int currentIndexThe current index in the set's key table; this is the index that will be removed ifremove()is called. -
valid
protected boolean validInternally employed by the iterator-reuse functionality. -
set
The set to iterate over.
-
-
Constructor Details
-
LongSetIterator
-
-
Method Details
-
reset
public void reset() -
findNextIndex
protected void findNextIndex() -
hasNext
public boolean hasNext()Returnstrueif the iteration has more elements. (In other words, returnstrueifLongIterator.next()would return an element rather than throwing an exception.) -
remove
public void remove() -
nextLong
public long nextLong()Description copied from interface:LongIteratorReturns the nextlongelement in the iteration.- Specified by:
nextLongin interfaceLongIterator- Returns:
- the next
longelement in the iteration
-
toList
Returns a newLongListcontaining the remaining items. Does not change the position of this iterator. -
appendInto
Append the remaining items that this can iterate through into the given PrimitiveCollection.OfLong. Does not change the position of this iterator.- Parameters:
coll- any modifiable PrimitiveCollection.OfLong; may have items appended into it- Returns:
- the given primitive collection
-