java.lang.Object
org.bzdev.util.SuffixArray.Iterator
- Enclosing class:
- SuffixArray
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
FieldsModifier and TypeFieldDescriptionprotected int
The value, after being updated by a call to doNext(), that the methodnext()
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 TypeMethodDescriptionprotected abstract void
doNext()
Get a new entry.int
Return the length of the current suffix or subsequence.boolean
hasNext()
Test if the iteration has a next elementfinal Integer
next()
Return the next element in the iteration.void
remove()
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 currentIndexThe value, after being updated by a call to doNext(), that the methodnext()
will return. The index is expected to be an index into a sequence array (not the suffix array). -
currentLength
protected int currentLengthThe current length of a suffix or subsequence that starts at the current index into the sequence array. -
hasMore
protected boolean hasMoreTrue if there are more entries and false otherwise. A constructor and calls todoNext()
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
Return the next element in the iteration. This element is an index into the sequence, not the suffix array. -
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 -
remove
Remove an element. This method is required by theIterator
interface, and is not implemented. AnUnsupportedOperationException
will be thrown if this method, which is an optional operation, is called.- Specified by:
remove
in interfaceIterator<Integer>
- Throws:
UnsupportedOperationException
- this operation is not supported.
-