Class StateSetEnumerator
java.lang.Object
jflex.state.StateSetEnumerator
- All Implemented Interfaces:
Iterator<Integer>, PrimitiveIterator<Integer, IntConsumer>, PrimitiveIterator.OfInt
Enumerates the states of a
StateSet. Also provides an iterator for native int.- Version:
- JFlex 1.9.1
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface PrimitiveIterator
PrimitiveIterator.OfDouble, PrimitiveIterator.OfInt, PrimitiveIterator.OfLong -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate long[]Reference to the array of the StateSet to iterate overprivate static final booleanLocal compile-time DEBUG flagprivate intCurrent index into the StateSet array.private longmask = 1 << offsetprivate intCurrent offset into the StateSet array -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new StateSetEnumerator that is not yet associated with a StateSet.StateSetEnumerator(StateSet states) Construct a StateSetEnumerator for a given StateSet. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidadvance()Advance to the next element in the set.booleanDetermine if there are further elements in the set to be returned.booleanhasNext()Iterator interface method fornextElement().intReturn the next element from the set.intnextInt()Iterator interface method forhasMoreElements()voidReset this enumerator/iterator and associate it with a given StateSet.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface PrimitiveIterator.OfInt
forEachRemaining, forEachRemaining, next
-
Field Details
-
DEBUG
private static final boolean DEBUGLocal compile-time DEBUG flag- See Also:
-
index
private int indexCurrent index into the StateSet array.index >= bits.lengthindicates that there are no further elements in the set. -
offset
private int offsetCurrent offset into the StateSet array -
mask
private long maskmask = 1 << offset -
bits
private long[] bitsReference to the array of the StateSet to iterate over
-
-
Constructor Details
-
StateSetEnumerator
public StateSetEnumerator()Creates a new StateSetEnumerator that is not yet associated with a StateSet.hasMoreElements()andnextElement()will throwNullPointerExceptionwhen used beforereset(StateSet) -
StateSetEnumerator
-
-
Method Details
-
reset
-
advance
private void advance()Advance to the next element in the set.Precondition: there are more elements in the set.
-
hasMoreElements
public boolean hasMoreElements()Determine if there are further elements in the set to be returned.- Returns:
- true iff there are more elements in the set.
-
nextElement
public int nextElement()Return the next element from the set.Precondition:
hasMoreElements()returns true- Returns:
- the next element.
- Throws:
NoSuchElementException- if there is no further element- See Also:
-
hasNext
public boolean hasNext()Iterator interface method fornextElement(). -
nextInt
public int nextInt()Iterator interface method forhasMoreElements()- Specified by:
nextIntin interfacePrimitiveIterator.OfInt
-