pub struct BloomFilter<K> { /* private fields */ }Expand description
A Bloom filter that keeps track of items of type K.
Implementations§
Source§impl<K: Hash> BloomFilter<K>
impl<K: Hash> BloomFilter<K>
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: &Self) -> f64
pub fn similarity(&self, other: &Self) -> f64
Compute the approximate similarity between two filters using the Jaccard Index.
Sourcepub fn overlap(&self, other: &Self) -> f64
pub fn overlap(&self, other: &Self) -> f64
Compute the approximate overlap between two filters using the overlap coefficient.
Sourcepub fn intersection(&self, other: &Self) -> Self
pub fn intersection(&self, other: &Self) -> Self
Compute the intersection of two Bloom filters.
Sourcepub fn is_comparable(&self, other: &Self) -> bool
pub fn is_comparable(&self, other: &Self) -> 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> Clone for BloomFilter<K>
impl<K: Clone> Clone for BloomFilter<K>
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 more