[][src]Struct contest_algorithms::string_proc::MultiMatcher

pub struct MultiMatcher<C: Hash + Eq> {
    pub trie: Trie<C>,
    pub pat_id: Vec<Option<usize>>,
    pub fail: Vec<usize>,
    pub fast: Vec<usize>,
}

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]

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

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.