pub struct MultiSieve<'a> { /* private fields */ }Expand description
A multi-pass sieve that supports any number of patterns.
Internally, patterns are partitioned into groups of at most 16 entries
so each group can reuse the existing SimdSieve
implementation. Candidate offsets from every group are then merged with a
k-way merge, preserving ascending order and removing duplicates.
§Errors
Returns the same construction errors as SimdSieve::new. In practice,
only an empty pattern set can fail because MultiSieve never forwards more
than 16 patterns to a single underlying sieve.
§Example
use simdsieve::MultiSieve;
let haystack = b"alpha beta gamma delta";
let patterns: &[&[u8]] = &[b"alpha", b"beta", b"gamma", b"delta"];
let matches: Vec<usize> = MultiSieve::new(haystack, patterns)
.unwrap()
.candidates()
.collect();
assert_eq!(matches, vec![0, 6, 11, 17]);Implementations§
Source§impl<'a> MultiSieve<'a>
impl<'a> MultiSieve<'a>
Sourcepub fn new_case_insensitive(
haystack: &'a [u8],
patterns: &[&'a [u8]],
) -> Result<Self>
pub fn new_case_insensitive( haystack: &'a [u8], patterns: &[&'a [u8]], ) -> Result<Self>
Sourcepub fn candidates(self) -> impl Iterator<Item = usize> + 'a
pub fn candidates(self) -> impl Iterator<Item = usize> + 'a
Iterates candidate positions from all pattern groups in sorted order.
If multiple groups report the same position, that offset is yielded only once.
Auto Trait Implementations§
impl<'a> Freeze for MultiSieve<'a>
impl<'a> RefUnwindSafe for MultiSieve<'a>
impl<'a> Send for MultiSieve<'a>
impl<'a> Sync for MultiSieve<'a>
impl<'a> Unpin for MultiSieve<'a>
impl<'a> UnsafeUnpin for MultiSieve<'a>
impl<'a> UnwindSafe for MultiSieve<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more