Function triple_accel::hamming::hamming_search_simd_with_opts [−][src]
pub fn hamming_search_simd_with_opts<'a>(
needle: &'a [u8],
haystack: &'a [u8],
k: u32,
search_type: SearchType
) -> Box<dyn Iterator<Item = Match> + 'a>
Expand description
Returns an iterator over Match
s by searching through the text haystack
for the
pattern needle
using SIMD, with extra options.
This is done by using SIMD to count mismatches at every position in haystack
.
This will automatically fall back to hamming_search_naive_with_opts
if AVX2 and SSE4.1
are not supported.
Null bytes/characters are not supported.
The length of needle
must be less than or equal to the length of haystack
.
This should be faster than hamming_search_naive_with_opts
.
Arguments
needle
- pattern string (slice)haystack
- text string (slice)k
- number of mismatches allowedsearch_type
- whether to only return the “best” matches with the lowest Hamming distance, or all matches
Panics
- When there are zero/null bytes in the
haystack
string.
Example
let matches: Vec<Match> = hamming_search_simd_with_opts(b"abc", b" abd", 1, SearchType::All).collect(); assert!(matches == vec![Match{start: 2, end: 5, k: 1}]);