[][src]Struct plum::StandardBloomFilter

pub struct StandardBloomFilter<T: ?Sized> { /* fields omitted */ }

A fast standard Bloom Filter implementation that requires only two hash functions, generated by std::collections::hash_map::DefaultHasher.

If an item is not present in the filter then contains is guaranteed to return false for the queried item.

The probability that contains returns true for an item that is not present in the filter is called the False Positive Rate.

Example Usage

use plum::StandardBloomFilter;

let items_count = 1_000_000;
let fp_rate = 0.01;

let mut bloom = StandardBloomFilter::new(items_count, fp_rate);
bloom.insert("item1");
bloom.contains("item1"); /* true */
bloom.contains("item2"); /* false */

Implementations

impl<T: ?Sized> StandardBloomFilter<T>[src]

pub fn new(items_count: usize, fp_rate: f64) -> Self[src]

Create a new StandardBloomFilter that expects to store items_count membership with a false positive rate of the value specified in fp_rate.

pub fn insert(&mut self, item: &T) where
    T: Hash
[src]

Insert item to the set.

pub fn contains(&mut self, item: &T) -> bool where
    T: Hash
[src]

Check if an item is present in the set. There can be false positives, but no false negatives.

Auto Trait Implementations

impl<T: ?Sized> RefUnwindSafe for StandardBloomFilter<T> where
    T: RefUnwindSafe

impl<T: ?Sized> Send for StandardBloomFilter<T> where
    T: Send

impl<T: ?Sized> Sync for StandardBloomFilter<T> where
    T: Sync

impl<T: ?Sized> Unpin for StandardBloomFilter<T> where
    T: Unpin

impl<T: ?Sized> UnwindSafe for StandardBloomFilter<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.