Skip to main content

horspool

Function horspool 

Source
pub fn horspool(pattern: &[u8], text: &[u8], i0: usize) -> Option<usize>
Expand description

An implementation of the Horspool algorithm.

Takes a pattern, a text text and a value i0 specifying at which index of the text it should start to search for the next occurence.

If the given text contains the given pattern, the algorithm returns the index i of the first letter of the first occurrence with i >= i0. If the pattern could not be found in the text, None is returned.

This algorithm terminates after finding one occurrence of the given pattern in the given text. If you want to find all occurrences, consider using horspool_all instead.