pub struct BloomFilter<T> { /* private fields */ }
Expand description

BloomFilter

An implementation of a bloom filter

Implementations§

Create a new BloomFilter given a hasher, the number of hash functions to use, and the size of the underlying bit array.

Typically, this function should not be called directly unless, the optimal number of hash functions and optimal array size are already known.

Create a BloomFilter by computing its optimal parameters.

This function computes the optimal array size using

-(n * ln(p)) / ln(2) ^ 2

and computes the optimal number of hash functions using

m / n * ln(2)

Insert a slice of bytes into the BloomFilter.

Insert a slice of slices of bytes into the BloomFilter.

Check whether a slice of bytes exists in the BloomFilter.

This is a probabilistic function that may return a false positive but will never return a false negative.

Examples
extern crate bloom_filter_rs as bloom_filter;

use std::vec::Vec;
use bloom_filter::{BloomFilter, Murmur3};

let words = vec!["Hello", "I", "am", "some", "words"];

let mut bloom_filter = BloomFilter::optimal(Murmur3, words.len() as u64, 0.01);

bloom_filter.insert_all(&words);

for word in words.iter() {
    assert!(bloom_filter.contains(&word));
}

Calculate the expected false positive rate given the current state of the BloomFilter.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.