Function algos::pattern::boyer_moore[][src]

pub fn boyer_moore(pattern: &[u8], find: &[u8]) -> Result<usize, usize>

Boyer-Moore: Search for the pattern in the find parameter in a slice.

It returns Ok holding the index of the first character of find that was found or Err holding the last index it searched if not find.

Case Time complexity Space complexity
Best: Ω(n/m)
Avrg: θ(n+m)
Worst: O(nm) O(m+δ)

Obs.: δ is the max size of u8.

Example

use algos::pattern;

let p = "ATCGGATTTCAGAAGCT".as_bytes();

let find = pattern::boyer_moore(&p, &"TTT".as_bytes());
assert_eq!(find, Ok(6));