public final class ByteSequenceIterator
extends java.lang.Object
implements java.util.Iterator<java.nio.ByteBuffer>
| Modifier and Type | Field and Description |
|---|---|
private int[] |
arcs
An arc stack for DFS when processing the automaton.
|
private byte[] |
buffer
A buffer for the current sequence of bytes from the current node to the
root.
|
private java.nio.ByteBuffer |
bufferWrapper
Reusable byte buffer wrapper around
buffer. |
private static int |
EXPECTED_MAX_STATES
Default expected depth of the recursion stack (estimated longest sequence
in the automaton).
|
private FSA |
fsa
The FSA to which this iterator belongs.
|
private java.nio.ByteBuffer |
nextElement
An internal cache for the next element in the FSA
|
private int |
position
Current processing depth in
arcs. |
| Constructor and Description |
|---|
ByteSequenceIterator(FSA fsa)
Create an instance of the iterator iterating over all automaton sequences.
|
ByteSequenceIterator(FSA fsa,
int node)
Create an instance of the iterator for a given node.
|
| Modifier and Type | Method and Description |
|---|---|
private java.nio.ByteBuffer |
advance()
Advances to the next available final state.
|
boolean |
hasNext()
Returns
true if there are still elements in this iterator. |
java.nio.ByteBuffer |
next() |
private void |
pushNode(int node)
Descends to a given node, adds its arcs to the stack to be traversed.
|
void |
remove()
Not implemented in this iterator.
|
ByteSequenceIterator |
restartFrom(int node)
Restart walking from
node. |
private static final int EXPECTED_MAX_STATES
private final FSA fsa
private java.nio.ByteBuffer nextElement
private byte[] buffer
private java.nio.ByteBuffer bufferWrapper
buffer.private int[] arcs
private int position
arcs.public ByteSequenceIterator(FSA fsa)
fsa - The automaton to iterate over.public ByteSequenceIterator(FSA fsa, int node)
fsa - The automaton to iterate over.node - The starting node's identifier (can be the FSA.getRootNode()).public ByteSequenceIterator restartFrom(int node)
node. Allows iterator reuse.node - Restart the iterator from node.this for call chaining.public boolean hasNext()
true if there are still elements in this iterator.hasNext in interface java.util.Iterator<java.nio.ByteBuffer>public java.nio.ByteBuffer next()
next in interface java.util.Iterator<java.nio.ByteBuffer>ByteBuffer with the sequence corresponding to the
next final state in the automaton.private final java.nio.ByteBuffer advance()
public void remove()
remove in interface java.util.Iterator<java.nio.ByteBuffer>private void pushNode(int node)