Struct pdatastructs::BloomFilter
[−]
[src]
pub struct BloomFilter { /* fields omitted */ }
Simple implementation of a BloomFilter
Methods
impl BloomFilter
[src]
fn with_params(m: usize, k: usize) -> BloomFilter
[src]
Create new, empty BloomFilter with internal parameters.
k
is the number of hash functionsm
is the number of bits used to store state
fn with_properties(n: usize, p: f64) -> BloomFilter
[src]
Create new, empty BloomFilter with given properties.
n
number of unique elements the BloomFilter is expected to hold, must be> 0
p
false positive property when querying the BloomFilter after addingn
unique elements, must be> 0
and< 1
Panics if the parameters are not in range.
fn k(&self) -> usize
[src]
Get k
(number of hash functions).
fn m(&self) -> usize
[src]
Get m
(number of stored bits).
fn add<T>(&mut self, obj: &T) where
T: Hash,
[src]
T: Hash,
Add new element to the BloomFilter.
If the same element is added multiple times or if an element results in the same hash signature, this method does not have any effect.
fn query<T>(&self, obj: &T) -> bool where
T: Hash,
[src]
T: Hash,
Guess if the given element was added to the BloomFilter.
fn clear(&mut self)
[src]
Clear state of the BloomFilter, so that it behaves like a fresh one.
fn is_empty(&self) -> bool
[src]
Check whether the BloomFilter is empty.
fn union(&mut self, other: &BloomFilter)
[src]
Add the entire content of another bloomfilter to this BloomFilter.
The result is the same as adding all elements added to other
to self
in the first
place.
Panics if k
and m
of the two BloomFilters are not identical.
fn guess_n(&self) -> usize
[src]
Guess the number of unique elements added to the BloomFilter.
Trait Implementations
impl Clone for BloomFilter
[src]
fn clone(&self) -> BloomFilter
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more