Struct MultiMatcher

Source
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>

Source

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.

Source

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].

Source

pub fn get_end_pos_and_pat_id( &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> 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.