Struct b100m_filter::Builder

source ·
pub struct Builder { /* private fields */ }
Expand description

A bloom filter builder

This type can be used to construct an instance of BloomFilter through a builder-like pattern.

Implementations§

source§

impl Builder

source

pub fn seed(self, seeds: &[[u8; 16]; 2]) -> Self

Sets the seed for this builder. The later constructed BloomFilter will use this seed when hashing items.

Examples
use b100m_filter::BloomFilter;

let bloom = BloomFilter::builder(4).seed(&[[0u8; 16]; 2]).hashes(4);
source

pub fn hashes(self, num_hashes: u64) -> BloomFilter

“Consumes” this builder, using the provided num_hashes to return an empty BloomFilter. For performance, the actual number of hashes performed internally will be rounded to down to the nearest multiple of 4.

Examples
use b100m_filter::BloomFilter;

let bloom = BloomFilter::builder(4).hashes(4);
source

pub fn expected_items(self, expected_num_items: usize) -> BloomFilter

“Consumes” this builder, using the provided expected_num_items to return an empty BloomFilter. More or less than expected_num_items may be inserted into BloomFilter, but the number of hashes per item is intially calculated to minimize false positive rate for exactly expected_num_items.

Examples
use b100m_filter::BloomFilter;

let bloom = BloomFilter::builder(4).expected_items(500);
source

pub fn items<I: ExactSizeIterator<Item = impl Hash>>( self, items: I ) -> BloomFilter

“Consumes” this builder and constructs a BloomFilter containing all values in items. The number of hashes per item is calculated based on items.len() to minimize false positive rate.

Examples
use b100m_filter::BloomFilter;

let bloom = BloomFilter::builder(4).items([1, 2, 3].iter());

Trait Implementations§

source§

impl Clone for Builder

source§

fn clone(&self) -> Builder

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
source§

impl Debug for Builder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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