Class PositionIterator

  • All Implemented Interfaces:
    java.lang.Iterable<Position>, java.util.Iterator<Position>

    public final class PositionIterator
    extends java.lang.Object
    implements java.util.Iterator<Position>, java.lang.Iterable<Position>
    Iterates over all unique positions in a TokenList.

    WARNING: the Position instance returned by next() will always be the same reference. If you want to save positions as you are iterating, you should call Position.clone() on the returned position.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Position get()
      Get the current position.
      boolean hasNext()
      Returns true if a next position exists.
      PositionIterator iterator()
      Implement iterator() to return self (for Iterable interface).
      Position next()
      void remove()
      void seek​(Position p)
      Expert: Seek to a position.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Method Detail

      • get

        public Position get()
        Get the current position.

        NOTE: this is undefined until next() has been called the first time.

      • seek

        public void seek​(Position p)
        Expert: Seek to a position.
      • iterator

        public PositionIterator iterator()
        Implement iterator() to return self (for Iterable interface).
        Specified by:
        iterator in interface java.lang.Iterable<Position>
      • hasNext

        public boolean hasNext()
        Returns true if a next position exists.
        Specified by:
        hasNext in interface java.util.Iterator<Position>
      • next

        public Position next()
        Specified by:
        next in interface java.util.Iterator<Position>
      • remove

        public final void remove()
        Specified by:
        remove in interface java.util.Iterator<Position>