Struct librualg::bloom_filter::BloomFilter[][src]

pub struct BloomFilter { /* fields omitted */ }

Bloom Filter

 use librualg::bloom_filter::BloomFilter;;

 let mut bloom_filter = BloomFilter::build(8 * 1024 * 1024, 1000000, 2);
 bloom_filter.insert("google");
 bloom_filter.insert("facebook");
 bloom_filter.insert("yandex");

 assert_eq!(bloom_filter.contains("google"), true);
 assert_eq!(bloom_filter.contains("facebook"), true);
 assert_eq!(bloom_filter.contains("yandex"), true);
 assert_eq!(bloom_filter.contains("microsoft"), false);
 assert_eq!(bloom_filter.contains("oracle"), false);
 assert_eq!(bloom_filter.contains("redhat"), false);

Implementations

impl BloomFilter[src]

pub fn build(n: usize, m: usize, k: usize) -> Self[src]

Build Bloom Filter

Arguments

  • n - bit array size (number of bytes)
  • m - number of inserted elements
  • k - number hash functions

pub fn insert(&mut self, key: &str)[src]

pub fn contains(&self, key: &str) -> bool[src]

pub fn get_false_positive_probability(&self) -> f64[src]

Auto Trait Implementations

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.