[−][src]Struct cbloom::Filter
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
Auto Trait Implementations
impl Send for Filter
impl Unpin for Filter
impl Sync for Filter
impl UnwindSafe for Filter
impl RefUnwindSafe for Filter
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,