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]
T: 'a + Copy + PartialEq + Into<usize>,
H: 'a + Searchable<Item = T>,
fn new(needle: &'a H) -> BoyerMoore<'a, H>
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."]
fn find_first_in<'b>(&'b self, haystack: &'b H) -> Option<usize>
Finds the first occurence of the search term in haystack and returns the index if it is found.
fn find_in<'b>(&'b self, haystack: &'b H) -> BoyerMooreIter<T, H>
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>>());
fn find_overlapping_in<'b>(&'b self, haystack: &'b H) -> BoyerMooreIter<T, H>
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>>());