[][src]Struct cbloom::Filter

pub struct Filter { /* fields omitted */ }

A concurrent Bloom filter.

Bloom filters are a probabilistic data structure, which allows you to insert elements, and later test if they were inserted. The filter will either know it doesn't contain the element, or that it might. It will never be "sure", hence the name "filter".

It works by having an array of bits. Every element is hashed into a sequence of these bits. The bits of the inserted elements are set to 1. When testing for membership, we simply AND the bits.

Methods

impl Filter[src]

pub fn new(bytes: usize, expected_elements: usize) -> Filter[src]

Create a new Bloom filter with the optimal number of hash functions.

This creates a Bloom filter with bytes bytes of internal data, and optimal number (for expected_elements number of elements) of hash functions.

pub fn with_size_and_hashers(bytes: usize, hashers: usize) -> Filter[src]

Create a new Bloom filter with some number of bytes and hashers.

This creates a Bloom filter with at least bytes bytes of internal data and hashers number of hash functions.

If hashers is 0, it will be rounded to 1.

pub fn clear(&self)[src]

Clear the Bloom filter.

This removes every element from the Bloom filter.

Note that it will not do so atomically, and it can remove elements inserted simultaneously to this function being called.

pub fn insert(&self, x: u64)[src]

Insert an element into the Bloom filter.

pub fn maybe_contains(&self, x: u64) -> bool[src]

Check if the Bloom filter potentially contains an element.

This returns true if we're not sure if the filter contains x or not, and false if we know that the filter does not contain x.

Trait Implementations

impl Debug for Filter[src]

Auto Trait Implementations

impl Unpin for Filter

impl Sync for Filter

impl Send for Filter

impl UnwindSafe for Filter

impl RefUnwindSafe for Filter

Blanket Implementations

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

impl<T> From<T> for 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.

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

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

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