Struct libbgs::markoff::BloomFilter

source ·
pub struct BloomFilter<T, F> { /* private fields */ }
Expand description

A Bloom Filter, a probabilistic set. Elements may be added to the filter, and then the filter may be tested for membership, with false positives. The false positivity rate is determined by the size of the Bloom filter and the number of hashes.

Implementations§

source§

impl<T, F> BloomFilter<T, F>where F: Fn(&T) -> usize + Send + Sync,

source

pub fn new(bits: usize, hashes: Vec<F>) -> BloomFilter<T, F>

Create a new Bloom filter, with the given size in bits and the given list of hashes to be applied to all members on addition and query.

source

pub fn add(&mut self, elem: &T)

Add elem to the Bloom filter.

source

pub fn is_member_prob(&self, elem: &T) -> bool

True if elem is in the set. If elem is not in the set, this method returns False; i.e., this method return false positives, but not false negatives.

source

pub fn is_member<G>(&self, elem: &T, confirm: G) -> boolwhere G: Fn(&T) -> bool,

True if elem is in the set, lazily confirming the result with the confirm closure to guard against false positives.

source

pub fn union(&mut self, other: &Self)

Modifies self to include elements from other. The false positivity rate of the resultant bloom filter will be greater than or equal to the maximum of the false positivity rates of the two operands.

Trait Implementations§

source§

impl<T, F> Clone for BloomFilter<T, F>

source§

fn clone(&self) -> BloomFilter<T, F>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<T, F> RefUnwindSafe for BloomFilter<T, F>where F: RefUnwindSafe, T: RefUnwindSafe,

§

impl<T, F> Send for BloomFilter<T, F>where F: Send + Sync, T: Send,

§

impl<T, F> Sync for BloomFilter<T, F>where F: Send + Sync, T: Sync,

§

impl<T, F> Unpin for BloomFilter<T, F>where T: Unpin,

§

impl<T, F> UnwindSafe for BloomFilter<T, F>where F: RefUnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.