1use crate::util::primitives::StateID;
23/// A collection of sentinel state IDs for Aho-Corasick automata.
4///
5/// This specifically enables the technique by which we determine which states
6/// are dead, matches or start states. Namely, by arranging states in a
7/// particular order, we can determine the type of a state simply by looking at
8/// its ID.
9#[derive(#[automatically_derived]
impl ::core::clone::Clone for Special {
#[inline]
fn clone(&self) -> Special {
Special {
max_special_id: ::core::clone::Clone::clone(&self.max_special_id),
max_match_id: ::core::clone::Clone::clone(&self.max_match_id),
start_unanchored_id: ::core::clone::Clone::clone(&self.start_unanchored_id),
start_anchored_id: ::core::clone::Clone::clone(&self.start_anchored_id),
}
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for Special {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f, "Special",
"max_special_id", &self.max_special_id, "max_match_id",
&self.max_match_id, "start_unanchored_id",
&self.start_unanchored_id, "start_anchored_id",
&&self.start_anchored_id)
}
}Debug)]
10pub(crate) struct Special {
11/// The maximum ID of all the "special" states. This corresponds either to
12 /// start_anchored_id when a prefilter is active and max_match_id when a
13 /// prefilter is not active. The idea here is that if there is no prefilter,
14 /// then there is no point in treating start states as special.
15pub(crate) max_special_id: StateID,
16/// The maximum ID of all the match states. Any state ID bigger than this
17 /// is guaranteed to be a non-match ID.
18 ///
19 /// It is possible and legal for max_match_id to be equal to
20 /// start_anchored_id, which occurs precisely in the case where the empty
21 /// string is a pattern that was added to the underlying automaton.
22pub(crate) max_match_id: StateID,
23/// The state ID of the start state used for unanchored searches.
24pub(crate) start_unanchored_id: StateID,
25/// The state ID of the start state used for anchored searches. This is
26 /// always start_unanchored_id+1.
27pub(crate) start_anchored_id: StateID,
28}
2930impl Special {
31/// Create a new set of "special" state IDs with all IDs initialized to
32 /// zero. The general idea here is that they will be updated and set to
33 /// correct values later.
34pub(crate) fn zero() -> Special {
35Special {
36 max_special_id: StateID::ZERO,
37 max_match_id: StateID::ZERO,
38 start_unanchored_id: StateID::ZERO,
39 start_anchored_id: StateID::ZERO,
40 }
41 }
42}