Package jflex.state

Class StateSetEnumerator

java.lang.Object
jflex.state.StateSetEnumerator
All Implemented Interfaces:
Iterator<Integer>, PrimitiveIterator<Integer,IntConsumer>, PrimitiveIterator.OfInt

public final class StateSetEnumerator extends Object implements PrimitiveIterator.OfInt
Enumerates the states of a StateSet. Also provides an iterator for native int.
Version:
JFlex 1.8.2
See Also:
  • Field Details

    • DEBUG

      private static final boolean DEBUG
      Local compile-time DEBUG flag
      See Also:
    • index

      private int index
      Current index into the StateSet array. index >= bits.length indicates that there are no further elements in the set.
    • offset

      private int offset
      Current offset into the StateSet array
    • mask

      private long mask
      mask = 1 << offset
    • bits

      private long[] bits
      Reference to the array of the StateSet to iterate over
  • Constructor Details

  • Method Details

    • reset

      public void reset(StateSet states)
      Reset this enumerator/iterator and associate it with a given StateSet.
      Parameters:
      states - the StateSet 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 for nextElement().
      Specified by:
      hasNext in interface Iterator<Integer>
    • nextInt

      public int nextInt()
      Iterator interface method for hasMoreElements()
      Specified by:
      nextInt in interface PrimitiveIterator.OfInt