/// Return matches of the given pattern.
/// Complexity O(m + k) for pattern of length m and k being the number of matching q-grams.
Return matches of the given pattern.
Complexity O(m + k) for pattern of length m and k being the number of matching q-grams.
Return matches of the given pattern . Complexity O ( m + k ) for pattern of length m and k being the number of matching q - grams .
pub fn matches(&self, pattern: &[u8], min_count: usize) -> Vec<Match> {
        let q = self.q as usize;
        let mut diagonals = collections::HashMap::new();
        for (i, qgram) in self.ranks.qgrams(self.q, pattern).enumerate() {
            for &p in self.qgram_matches(qgram) {
                let diagonal = p - i;
                match diagonals.entry(diagonal) {
                    Entry::Vacant(v) => {
                        v.insert(Match {
                            pattern: Interval {
                                start: i,
                                stop: i + q,
                            },
                            text: Interval {
                                start: p,
                                stop: p + q,
                            },
                            count: 1,
                        });
                    }
                    Entry::Occupied(mut o) => {
                        let m = o.get_mut();
                        m.pattern.stop = i + q;
                        m.text.stop = p + q;
                        m.count += 1;
                    }
                }
            }
        }
        diagonals
            .into_iter()
            .filter_map(|(_, m)| if m.count >= min_count { Some(m) } else { None })
            .collect()
    }
pub fn matches ( & self , pattern : & [ u8 ] , min_count : usize ) -> Vec < Match > { let q = self . q as usize ; let mut diagonals = collections :: HashMap :: new ( ) ; for ( i , qgram ) in self . ranks . qgrams ( self . q , pattern ) . enumerate ( ) { for & p in self . qgram_matches ( qgram ) { let diagonal = p - i ; match diagonals . entry ( diagonal ) { Entry :: Vacant ( v ) => { v . insert ( Match { pattern : Interval { start : i , stop : i + q , } , text : Interval { start : p , stop : p + q , } , count : 1 , } ) ; } Entry :: Occupied ( mut o ) => { let m = o . get_mut ( ) ; m . pattern . stop = i + q ; m . text . stop = p + q ; m . count += 1 ; } } } } diagonals . into_iter ( ) . filter_map ( | ( _ , m ) | if m . count >= min_count { Some ( m ) } else { None } ) . collect ( ) }
Return matches of the given pattern.
Return matches of the given pattern .
&self
pattern
&[u8]
min_count
usize