pub struct DenseTransitions {
pub transitions: Box<[StateID]>,
}
Expand description
A sequence of transitions used to represent a dense state.
This is the primary representation of a Dense
state. It
provides constant time matching. That is, given a byte in a haystack and
a DenseTransitions
, one can determine if the state matches in constant
time.
This is in contrast to SparseTransitions
, whose time complexity is
necessarily bigger than constant time. Also in contrast, DenseTransitions
usually requires (much) more heap memory.
Fields§
§transitions: Box<[StateID]>
A dense representation of this state’s transitions on the heap. This always has length 256.
Implementations§
Source§impl DenseTransitions
impl DenseTransitions
Sourcepub fn matches(&self, haystack: &[u8], at: usize) -> Option<StateID>
pub fn matches(&self, haystack: &[u8], at: usize) -> Option<StateID>
This follows the matching transition for a particular byte.
The matching transition is found by looking for a transition that
doesn’t correspond to StateID::ZERO
for the byte at
the given
position in haystack
.
If at >= haystack.len()
, then this returns None
.
Sourcepub fn matches_byte(&self, byte: u8) -> Option<StateID>
pub fn matches_byte(&self, byte: u8) -> Option<StateID>
This follows the matching transition for a particular byte.
The matching transition is found by looking for a transition that
doesn’t correspond to StateID::ZERO
for the given byte
.
If at >= haystack.len()
, then this returns None
.
Trait Implementations§
Source§impl Clone for DenseTransitions
impl Clone for DenseTransitions
Source§fn clone(&self) -> DenseTransitions
fn clone(&self) -> DenseTransitions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more