Class SuffixArray.Iterator

java.lang.Object
org.bzdev.util.SuffixArray.Iterator
All Implemented Interfaces:
Iterator<Integer>
Enclosing class:
SuffixArray

public abstract static class SuffixArray.Iterator extends Object implements Iterator<Integer>
Iterator for a suffix array. This iterator provides a sequence of indices into a sequence and a corresponding length, thus allowing one to iterate through a series of subsequences.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
    The value, after being updated by a call to doNext(), that the method next() will return.
    protected int
    The current length of a suffix or subsequence that starts at the current index into the sequence array.
    protected boolean
    True if there are more entries and false otherwise.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    Get a new entry.
    int
    Return the length of the current suffix or subsequence.
    boolean
    Test if the iteration has a next element
    final Integer
    Return the next element in the iteration.
    void
    Remove an element.

    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

    forEachRemaining
  • Field Details

    • currentIndex

      protected int currentIndex
      The value, after being updated by a call to doNext(), that the method next() will return. The index is expected to be an index into a sequence array (not the suffix array).
    • currentLength

      protected int currentLength
      The current length of a suffix or subsequence that starts at the current index into the sequence array.
    • hasMore

      protected boolean hasMore
      True if there are more entries and false otherwise. A constructor and calls to doNext() are expected to set this value.
  • Method Details

    • doNext

      protected abstract void doNext()
      Get a new entry. This method must update three protected fields as appropriate: currentIndex, currentLength, and hasMore. Subclasses will typically provide additional fields to track the state of the iteration. This method is called by next().
    • next

      public final Integer next()
      Return the next element in the iteration. This element is an index into the sequence, not the suffix array.
      Specified by:
      next in interface Iterator<Integer>
      Returns:
      the next element in the iteration
    • getLength

      public int getLength()
      Return the length of the current suffix or subsequence.
      Returns:
      the length of the current suffix or subsequence; 0 if Iterator.next() has not been called
    • hasNext

      public boolean hasNext()
      Test if the iteration has a next element
      Specified by:
      hasNext in interface Iterator<Integer>
      Returns:
      true if the iteration has more elements; false otherwise
    • remove

      public void remove() throws UnsupportedOperationException
      Remove an element. This method is required by the Iterator interface, and is not implemented. An UnsupportedOperationException will be thrown if this method, which is an optional operation, is called.
      Specified by:
      remove in interface Iterator<Integer>
      Throws:
      UnsupportedOperationException - this operation is not supported.