pub fn naive_all(pattern: &[u8], text: &[u8]) -> Vec<usize>Expand description
A simple algorithm for matching a single pattern on a text returning all occurrences.
Takes a pattern, and text text.
If the given text contains the given pattern, the algorithm returns the indexes of the first letters of all found occurrences. If the pattern could not be found in the text, an empty vector is returned.
§When to Use It
Probably never. This algorithm is the most simple approach to matching a pattern on a text. Could be useful for comparing runtimes or correctness with other algorithms.
§How It Works
The algorithm calls the naive algorithm starting with a the i0
parameter being 0. After the naive algorithm returns, it calls that same
algorithm again with an i0 parameter of the position in text right after
the found occurrence.