pub struct MultiMatcher<C: Hash + Eq> {
pub trie: Trie<C>,
pub pat_id: Vec<Option<usize>>,
pub fail: Vec<usize>,
pub fast: Vec<usize>,
}
Expand description
Multi-pattern matching with the Aho-Corasick algorithm
Fields§
§trie: Trie<C>
A prefix trie storing the string patterns to search for.
pat_id: Vec<Option<usize>>
Stores which completed pattern string each node corresponds to.
fail: Vec<usize>
Aho-Corasick failure automaton. fail[i] is the node corresponding to the longest prefix-suffix of the node corresponding to i.
fast: Vec<usize>
Shortcut to the next match along the failure chain, or to the root.
Implementations§
Source§impl<C: Hash + Eq> MultiMatcher<C>
impl<C: Hash + Eq> MultiMatcher<C>
Sourcepub fn new(
patterns: impl IntoIterator<Item = impl IntoIterator<Item = C>>,
) -> Self
pub fn new( patterns: impl IntoIterator<Item = impl IntoIterator<Item = C>>, ) -> Self
Precomputes the automaton that allows linear-time string matching. If there are duplicate patterns, all but one copy will be ignored.
Sourcepub fn ac_match(&self, text: impl IntoIterator<Item = C>) -> Vec<usize>
pub fn ac_match(&self, text: impl IntoIterator<Item = C>) -> Vec<usize>
Aho-Corasick algorithm, sets @return[i] = node corresponding to longest prefix of some pattern matching a suffix of text[0..=i].
Auto Trait Implementations§
impl<C> Freeze for MultiMatcher<C>
impl<C> RefUnwindSafe for MultiMatcher<C>where
C: RefUnwindSafe,
impl<C> Send for MultiMatcher<C>where
C: Send,
impl<C> Sync for MultiMatcher<C>where
C: Sync,
impl<C> Unpin for MultiMatcher<C>where
C: Unpin,
impl<C> UnwindSafe for MultiMatcher<C>where
C: UnwindSafe,
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
Mutably borrows from an owned value. Read more