pub struct BloomFilter { /* private fields */ }
Expand description
A Bloom Filter.
This implementation uses the Kirsch-Mitzenmacher optimization to derive k
hash functions
from two hash values, which are in turn derived from a single Digest. This provides
efficient hashing for BloomFilter::insert and BloomFilter::contains operations.
Implementations§
Source§impl BloomFilter
impl BloomFilter
Sourcepub fn new(hashers: NonZeroU8, bits: NonZeroUsize) -> Self
pub fn new(hashers: NonZeroU8, bits: NonZeroUsize) -> Self
Creates a new BloomFilter with hashers
hash functions and bits
bits.
Sourcepub fn insert(&mut self, item: &[u8])
pub fn insert(&mut self, item: &[u8])
Inserts an item into the BloomFilter.
Sourcepub fn contains(&self, item: &[u8]) -> bool
pub fn contains(&self, item: &[u8]) -> bool
Checks if an item is possibly in the BloomFilter.
Returns true
if the item is probably in the set, and false
if it is definitely not.
Trait Implementations§
Source§impl Clone for BloomFilter
impl Clone for BloomFilter
Source§fn clone(&self) -> BloomFilter
fn clone(&self) -> BloomFilter
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for BloomFilter
impl Debug for BloomFilter
Source§impl EncodeSize for BloomFilter
impl EncodeSize for BloomFilter
Source§fn encode_size(&self) -> usize
fn encode_size(&self) -> usize
Returns the encoded size of this value (in bytes).
Source§impl PartialEq for BloomFilter
impl PartialEq for BloomFilter
Source§impl Read for BloomFilter
impl Read for BloomFilter
Source§impl Write for BloomFilter
impl Write for BloomFilter
impl Eq for BloomFilter
impl StructuralPartialEq for BloomFilter
Auto Trait Implementations§
impl Freeze for BloomFilter
impl RefUnwindSafe for BloomFilter
impl Send for BloomFilter
impl Sync for BloomFilter
impl Unpin for BloomFilter
impl UnwindSafe for BloomFilter
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Encode for Twhere
T: Write + EncodeSize,
impl<T> Encode for Twhere
T: Write + EncodeSize,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more