Struct regex_automata::sparse::ByteClass
source · pub struct ByteClass<T: AsRef<[u8]>, S: StateID = usize>(_);
Expand description
A sparse DFA that shrinks its alphabet.
Alphabet shrinking is achieved by using a set of equivalence classes instead of using all possible byte values. Any two bytes belong to the same equivalence class if and only if they can be used interchangeably anywhere in the DFA while never discriminating between a match and a non-match.
Unlike dense DFAs, sparse DFAs do not tend to benefit nearly as much from using byte classes. In some cases, using byte classes can even marginally increase the size of a sparse DFA’s transition table. The reason for this is that a sparse DFA already compacts each state’s transitions separate from whether byte classes are used.
Generally, it isn’t necessary to use this type directly, since a
SparseDFA
can be used for searching directly. One possible reason why
one might want to use this type directly is if you are implementing your
own search routines by walking a DFA’s transitions directly. In that case,
you’ll want to use this type (or any of the other DFA variant types)
directly, since they implement next_state
more efficiently.
Trait Implementations§
source§impl<T: AsRef<[u8]>, S: StateID> DFA for ByteClass<T, S>
impl<T: AsRef<[u8]>, S: StateID> DFA for ByteClass<T, S>
source§fn start_state(&self) -> S
fn start_state(&self) -> S
source§fn is_match_state(&self, id: S) -> bool
fn is_match_state(&self, id: S) -> bool
source§fn is_dead_state(&self, id: S) -> bool
fn is_dead_state(&self, id: S) -> bool
source§fn is_match_or_dead_state(&self, id: S) -> bool
fn is_match_or_dead_state(&self, id: S) -> bool
is_match_state(id)
or is_dead_state(id)
must return true. Read moresource§fn is_anchored(&self) -> bool
fn is_anchored(&self) -> bool
source§fn next_state(&self, current: S, input: u8) -> S
fn next_state(&self, current: S, input: u8) -> S
source§unsafe fn next_state_unchecked(&self, current: S, input: u8) -> S
unsafe fn next_state_unchecked(&self, current: S, input: u8) -> S
next_state
, but its implementation may look up the next state
without memory safety checks such as bounds checks. As such, callers
must ensure that the given identifier corresponds to a valid DFA
state. Implementors must, in turn, ensure that this routine is safe
for all valid state identifiers and for all possible u8
values.source§fn is_match(&self, bytes: &[u8]) -> bool
fn is_match(&self, bytes: &[u8]) -> bool
source§fn shortest_match(&self, bytes: &[u8]) -> Option<usize>
fn shortest_match(&self, bytes: &[u8]) -> Option<usize>
source§fn find(&self, bytes: &[u8]) -> Option<usize>
fn find(&self, bytes: &[u8]) -> Option<usize>
None
is returned. Read moresource§fn rfind(&self, bytes: &[u8]) -> Option<usize>
fn rfind(&self, bytes: &[u8]) -> Option<usize>
None
is returned. In other words, this has the same
match semantics as find
, but in reverse. Read moresource§fn is_match_at(&self, bytes: &[u8], start: usize) -> bool
fn is_match_at(&self, bytes: &[u8], start: usize) -> bool
is_match
, but starts the search at the given
offset. Read moresource§fn shortest_match_at(&self, bytes: &[u8], start: usize) -> Option<usize>
fn shortest_match_at(&self, bytes: &[u8], start: usize) -> Option<usize>
shortest_match
, but starts the search at the
given offset. Read more