/// Return exact matches (substrings) of the given pattern.
/// Complexity O(m + k) for pattern of length m and k being the number of matching q-grams.
///
/// An exact match is a substring of `pattern` occurring in the text of length at least `q`.
Return exact matches (substrings) of the given pattern.
Complexity O(m + k) for pattern of length m and k being the number of matching q-grams.

An exact match is a substring of `pattern` occurring in the text of length at least `q`.
Return exact matches ( substrings ) of the given pattern . Complexity O ( m + k ) for pattern of length m and k being the number of matching q - grams . An exact match is a substring of ` pattern ` occurring in the text of length at least ` q ` .
pub fn exact_matches(&self, pattern: &[u8]) -> Vec<ExactMatch> {
        let q = self.q as usize;
        let mut diagonals = collections::HashMap::new();
        let mut matches = Vec::new();
        for (i, qgram) in self.ranks.qgrams(self.q, pattern).enumerate() {
            for &p in self.qgram_matches(qgram) {
                let diagonal = p as i32 - i as i32;
                match diagonals.entry(diagonal) {
                    Entry::Vacant(v) => {
                        v.insert(ExactMatch {
                            pattern: Interval {
                                start: i,
                                stop: i + q,
                            },
                            text: Interval {
                                start: p,
                                stop: p + q,
                            },
                        });
                    }
                    Entry::Occupied(mut o) => {
                        let m = o.get_mut();
                        if m.pattern.stop - q + 1 != i {
                            // discontinue match
                            matches.push(*m);
                            // start new match
                            m.pattern.start = i;
                            m.text.start = p;
                        }
                        m.pattern.stop = i + q;
                        m.text.stop = p + q;
                    }
                }
            }
        }
        for (_, m) in diagonals {
            matches.push(m);
        }
        matches
    }
pub fn exact_matches ( & self , pattern : & [ u8 ] ) -> Vec < ExactMatch > { let q = self . q as usize ; let mut diagonals = collections :: HashMap :: new ( ) ; let mut matches = Vec :: new ( ) ; for ( i , qgram ) in self . ranks . qgrams ( self . q , pattern ) . enumerate ( ) { for & p in self . qgram_matches ( qgram ) { let diagonal = p as i32 - i as i32 ; match diagonals . entry ( diagonal ) { Entry :: Vacant ( v ) => { v . insert ( ExactMatch { pattern : Interval { start : i , stop : i + q , } , text : Interval { start : p , stop : p + q , } , } ) ; } Entry :: Occupied ( mut o ) => { let m = o . get_mut ( ) ; if m . pattern . stop - q + 1 != i { // discontinue match matches . push ( * m ) ; // start new match m . pattern . start = i ; m . text . start = p ; } m . pattern . stop = i + q ; m . text . stop = p + q ; } } } } for ( _ , m ) in diagonals { matches . push ( m ) ; } matches }
Return exact matches (substrings) of the given pattern.
Return exact matches ( substrings ) of the given pattern .
&self
pattern
&[u8]