Struct cbloom::Filter [] [src]

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]

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.

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.

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 simulatenously to this function being called.

Insert an element into the Bloom filter.

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.