Struct aho_corasick::nfa::noncontiguous::State
source · pub(crate) struct State {
sparse: StateID,
dense: StateID,
matches: StateID,
fail: StateID,
depth: SmallIndex,
}
Expand description
A representation of a sparse NFA state for an Aho-Corasick automaton.
It contains the transitions to the next state, a failure transition for cases where there exists no other transition for the current input byte and the matches implied by visiting this state (if any).
Fields§
§sparse: StateID
A pointer to NFA::trans
corresponding to the head of a linked list
containing all of the transitions for this state.
This is StateID::ZERO
if and only if this state has zero transitions.
dense: StateID
A pointer to a row of N
transitions in NFA::dense
. These
transitions correspond precisely to what is obtained by traversing
sparse
, but permits constant time lookup.
When this is zero (which is true for most states in the default configuration), then this state has no dense representation.
Note that N
is equal to NFA::byte_classes::alphabet_len()
. This is
typically much less than 256 (the maximum value).
matches: StateID
A pointer to NFA::matches
corresponding to the head of a linked list
containing all of the matches for this state.
This is StateID::ZERO
if and only if this state is not a match state.
fail: StateID
The state that should be transitioned to if the current byte in the haystack does not have a corresponding transition defined in this state.
depth: SmallIndex
The depth of this state. Specifically, this is the distance from this state to the starting state. (For the special sentinel states DEAD and FAIL, their depth is always 0.) The depth of a starting state is 0.
Note that depth is currently not used in this non-contiguous NFA. It may in the future, but it is used in the contiguous NFA. Namely, it permits an optimization where states near the starting state have their transitions stored in a dense fashion, but all other states have their transitions stored in a sparse fashion. (This non-contiguous NFA uses a sparse representation for all states unconditionally.) In any case, this is really the only convenient place to compute and store this information, which we need when building the contiguous NFA.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for State
impl RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnwindSafe for State
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)