pub struct BloomFilter<K> { /* private fields */ }
Expand description
A Bloom filter that keeps track of items of type K
.
Implementations§
Source§impl<K> BloomFilter<K>where
K: Hash,
impl<K> BloomFilter<K>where
K: Hash,
Sourcepub fn new(capacity: usize) -> BloomFilter<K>
pub fn new(capacity: usize) -> BloomFilter<K>
Return a new Bloom filter with a given approximate item capacity.
The default false positive probability is set and defined by [DEFAULT_FALSE_POS
].
Sourcepub fn with_size(nbytes: usize) -> BloomFilter<K>
pub fn with_size(nbytes: usize) -> BloomFilter<K>
Return a new Bloom filter given a size in bytes for the filter.
Sourcepub fn with_rate(capacity: usize, fp_rate: f64) -> BloomFilter<K>
pub fn with_rate(capacity: usize, fp_rate: f64) -> BloomFilter<K>
Return a new Bloom filter with a given approximate item capacity and a desired false positive rate.
Sourcepub fn insert(&mut self, item: &K)
pub fn insert(&mut self, item: &K)
Set an item in the Bloom filter. This operation is idempotent with regards to each unique item. Each item must implement the Hash trait.
Sourcepub fn contains(&self, item: &K) -> bool
pub fn contains(&self, item: &K) -> bool
Return whether or not a given item is likely in the Bloom filter or not. There is a
possibility for a false positive with the probability being under the Bloom filter’s p
value, but a false negative will never occur.
Sourcepub fn similarity(&self, other: &BloomFilter<K>) -> f64
pub fn similarity(&self, other: &BloomFilter<K>) -> f64
Compute the approximate similarity between two filters using the Jaccard Index.
Sourcepub fn overlap(&self, other: &BloomFilter<K>) -> f64
pub fn overlap(&self, other: &BloomFilter<K>) -> f64
Compute the approximate overlap between two filters using the overlap coefficient.
Sourcepub fn union(&self, other: &BloomFilter<K>) -> BloomFilter<K>
pub fn union(&self, other: &BloomFilter<K>) -> BloomFilter<K>
Compute the union of two Bloom filters.
Sourcepub fn intersection(&self, other: &BloomFilter<K>) -> BloomFilter<K>
pub fn intersection(&self, other: &BloomFilter<K>) -> BloomFilter<K>
Compute the intersection of two Bloom filters.
Sourcepub fn is_comparable(&self, other: &BloomFilter<K>) -> bool
pub fn is_comparable(&self, other: &BloomFilter<K>) -> bool
Check whether two filters can be compared, intersected and unioned.
Trait Implementations§
Source§impl<K> AsRef<[u8]> for BloomFilter<K>
impl<K> AsRef<[u8]> for BloomFilter<K>
Source§impl<K> Clone for BloomFilter<K>where
K: Clone,
impl<K> Clone for BloomFilter<K>where
K: Clone,
Source§fn clone(&self) -> BloomFilter<K>
fn clone(&self) -> BloomFilter<K>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<K> Debug for BloomFilter<K>where
K: Debug,
impl<K> Debug for BloomFilter<K>where
K: Debug,
Source§impl From<BloomFilter<RepoId>> for Filter
impl From<BloomFilter<RepoId>> for Filter
Source§fn from(bloom: BloomFilter<RepoId>) -> Self
fn from(bloom: BloomFilter<RepoId>) -> Self
Source§impl<K> PartialEq for BloomFilter<K>
impl<K> PartialEq for BloomFilter<K>
impl<K> Eq for BloomFilter<K>
Auto Trait Implementations§
impl<K> Freeze for BloomFilter<K>
impl<K> RefUnwindSafe for BloomFilter<K>where
K: RefUnwindSafe,
impl<K> Send for BloomFilter<K>where
K: Send,
impl<K> Sync for BloomFilter<K>where
K: Sync,
impl<K> Unpin for BloomFilter<K>where
K: Unpin,
impl<K> UnwindSafe for BloomFilter<K>where
K: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
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>
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