[−][src]Struct contest_algorithms::string_proc::MultiMatcher
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
impl<C: Hash + Eq> MultiMatcher<C>
[src]
pub fn new(patterns: Vec<impl IntoIterator<Item = C>>) -> Self
[src]
Precomputes the automaton that allows linear-time string matching. If there are duplicate patterns, all but one copy will be ignored.
pub fn ac_match(&self, text: &[C]) -> Vec<usize>
[src]
Aho-Corasick algorithm, sets match_nodes[i] = node corresponding to longest prefix of some pattern matching a suffix of text[0..=i].
pub fn get_end_pos_and_pat_id(
&self,
match_nodes: &[usize]
) -> Vec<(usize, usize)>
[src]
&self,
match_nodes: &[usize]
) -> Vec<(usize, usize)>
For each non-empty match, returns where in the text it ends, and the index of the corresponding pattern.
Auto Trait Implementations
impl<C> RefUnwindSafe for MultiMatcher<C> where
C: RefUnwindSafe,
C: RefUnwindSafe,
impl<C> Send for MultiMatcher<C> where
C: Send,
C: Send,
impl<C> Sync for MultiMatcher<C> where
C: Sync,
C: Sync,
impl<C> Unpin for MultiMatcher<C> where
C: Unpin,
C: Unpin,
impl<C> UnwindSafe for MultiMatcher<C> where
C: UnwindSafe,
C: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,