Package jflex.state

Class StateSetEnumerator

  • All Implemented Interfaces:
    java.util.Iterator<java.lang.Integer>, java.util.PrimitiveIterator<java.lang.Integer,​java.util.function.IntConsumer>, java.util.PrimitiveIterator.OfInt

    public final class StateSetEnumerator
    extends java.lang.Object
    implements java.util.PrimitiveIterator.OfInt
    Enumerates the states of a StateSet. Also provides an iterator for native int.
    Version:
    JFlex 1.9.1
    See Also:
    StateSet
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface java.util.PrimitiveIterator

        java.util.PrimitiveIterator.OfDouble, java.util.PrimitiveIterator.OfInt, java.util.PrimitiveIterator.OfLong
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private long[] bits
      Reference to the array of the StateSet to iterate over
      private static boolean DEBUG
      Local compile-time DEBUG flag
      private int index
      Current index into the StateSet array.
      private long mask
      mask = 1 << offset
      private int offset
      Current offset into the StateSet array
    • Constructor Summary

      Constructors 
      Constructor Description
      StateSetEnumerator()
      Creates a new StateSetEnumerator that is not yet associated with a StateSet.
      StateSetEnumerator​(StateSet states)
      Construct a StateSetEnumerator for a given StateSet.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void advance()
      Advance to the next element in the set.
      boolean hasMoreElements()
      Determine if there are further elements in the set to be returned.
      boolean hasNext()
      Iterator interface method for nextElement().
      int nextElement()
      Return the next element from the set.
      int nextInt()
      Iterator interface method for hasMoreElements()
      void reset​(StateSet states)
      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.Iterator

        remove
      • Methods inherited from interface java.util.PrimitiveIterator.OfInt

        forEachRemaining, forEachRemaining, next
    • Field Detail

      • DEBUG

        private static final boolean DEBUG
        Local compile-time DEBUG flag
        See Also:
        Constant Field Values
      • 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 Detail

      • StateSetEnumerator

        public StateSetEnumerator()
        Creates a new StateSetEnumerator that is not yet associated with a StateSet. hasMoreElements() and nextElement() will throw NullPointerException when used before reset(StateSet)
      • StateSetEnumerator

        public StateSetEnumerator​(StateSet states)
        Construct a StateSetEnumerator for a given StateSet. This should be the default constructor to use.
        Parameters:
        states - the StateSet object to iterate over.
        See Also:
        StateSet.states()
    • Method Detail

      • 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:
        java.util.NoSuchElementException - if there is no further element
        See Also:
        hasMoreElements()
      • hasNext

        public boolean hasNext()
        Iterator interface method for nextElement().
        Specified by:
        hasNext in interface java.util.Iterator<java.lang.Integer>
      • nextInt

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