Package jflex.state
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.8.2
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.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 boolean
Local compile-time DEBUG flagprivate int
Current index into the StateSet array.private long
mask = 1 << offset
private int
Current 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 void
advance()
Advance to the next element in the set.boolean
Determine if there are further elements in the set to be returned.boolean
hasNext()
Iterator interface method fornextElement()
.int
Return the next element from the set.int
nextInt()
Iterator interface method forhasMoreElements()
void
Reset this enumerator/iterator and associate it with a given StateSet.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.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.length
indicates 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 throwNullPointerException
when used beforereset(StateSet)
-
StateSetEnumerator
Construct a StateSetEnumerator for a given StateSet. This should be the default constructor to use.- Parameters:
states
- theStateSet
object to iterate over.- See Also:
-
-
Method Details
-
reset
Reset this enumerator/iterator and associate it with a given StateSet.- Parameters:
states
- theStateSet
object to iterate over.
-
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:
nextInt
in interfacePrimitiveIterator.OfInt
-