Package org.apache.lucene.util.automaton
Class FiniteStringsIterator
- java.lang.Object
-
- org.apache.lucene.util.automaton.FiniteStringsIterator
-
- Direct Known Subclasses:
LimitedFiniteStringsIterator
public class FiniteStringsIterator extends java.lang.Object
Iterates all accepted strings.If the
Automaton
has cycles then this iterator may throw anIllegalArgumentException
, but this is not guaranteed!Be aware that the iteration order is implementation dependent and may change across releases.
If the automaton is not determinized then it's possible this iterator will return duplicates.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
FiniteStringsIterator.PathNode
Nodes for path stack.
-
Field Summary
Fields Modifier and Type Field Description private Automaton
a
Automaton to create finite string from.private boolean
emitEmptyString
Emit empty string?.private static IntsRef
EMPTY
Empty string.private int
endState
The state where each path should stop or -1 if only accepted states should be final.private FiniteStringsIterator.PathNode[]
nodes
Stack to hold our current state in the recursion/iteration.private java.util.BitSet
pathStates
Tracks which states are in the current path, for cycle detection.private IntsRefBuilder
string
Builder for current finite string.
-
Constructor Summary
Constructors Constructor Description FiniteStringsIterator(Automaton a)
Constructor.FiniteStringsIterator(Automaton a, int startState, int endState)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
growStack(int depth)
Grow path stack, if required.IntsRef
next()
Generate next finite string.
-
-
-
Field Detail
-
EMPTY
private static final IntsRef EMPTY
Empty string.
-
a
private final Automaton a
Automaton to create finite string from.
-
endState
private final int endState
The state where each path should stop or -1 if only accepted states should be final.
-
pathStates
private final java.util.BitSet pathStates
Tracks which states are in the current path, for cycle detection.
-
string
private final IntsRefBuilder string
Builder for current finite string.
-
nodes
private FiniteStringsIterator.PathNode[] nodes
Stack to hold our current state in the recursion/iteration.
-
emitEmptyString
private boolean emitEmptyString
Emit empty string?.
-
-
Constructor Detail
-
FiniteStringsIterator
public FiniteStringsIterator(Automaton a)
Constructor.- Parameters:
a
- Automaton to create finite string from.
-
FiniteStringsIterator
public FiniteStringsIterator(Automaton a, int startState, int endState)
Constructor.- Parameters:
a
- Automaton to create finite string from.startState
- The starting state for each path.endState
- The state where each path should stop or -1 if only accepted states should be final.
-
-
Method Detail
-
next
public IntsRef next()
Generate next finite string. The return value is just valid until the next call of this method!- Returns:
- Finite string or null, if no more finite strings are available.
-
growStack
private void growStack(int depth)
Grow path stack, if required.
-
-