Struct needle::boyer_moore::BoyerMoore [] [src]

pub struct BoyerMoore<'a, H: 'a + ?Sized> { /* fields omitted */ }

Methods

impl<'a, H: ?Sized, T> BoyerMoore<'a, H> where
    T: 'a + Copy + PartialEq + Into<usize>,
    H: 'a + Searchable<Item = T>, 
[src]

Construct a new Boyer-Moore search object, and pre-compute the skip tables. If you intend to search for the same needle in multiple haystacks, it is more efficient to create just one instance and the re-use it."]

Finds the first occurence of the search term in haystack and returns the index if it is found.

Returns an iterator that will produce the indices of the needle in the haystack. This iterator will not find overlapping matches; the first character of a match will start after the last character of the previous match.

Example

use needle::BoyerMoore;
let needle = BoyerMoore::new(&b"aaba"[..]);
let haystack = b"aabaabaabaabaaba";
assert_eq!(vec![0,6,12], needle.find_in(haystack).collect::<Vec<usize>>());

Returns an iterator that will produce the indices of the needle in the haystack. This iterator will find overlapping matches; the first character of a match is allowed to be matched from within the previous match.

Example

use needle::BoyerMoore;
let needle = BoyerMoore::new(&b"aaba"[..]);
let haystack = b"aabaabaabaabaaba";
assert_eq!(vec![0,3,6,9,12], needle.find_overlapping_in(haystack).collect::<Vec<usize>>());