Struct bloomfilter::Bloom
source · pub struct Bloom<T: ?Sized> { /* private fields */ }
Expand description
Bloom filter structure
Implementations§
source§impl<T: ?Sized> Bloom<T>
impl<T: ?Sized> Bloom<T>
sourcepub fn new_with_seed(
bitmap_size: usize,
items_count: usize,
seed: &[u8; 32],
) -> Self
pub fn new_with_seed( bitmap_size: usize, items_count: usize, seed: &[u8; 32], ) -> Self
Create a new bloom filter structure. bitmap_size is the size in bytes (not bits) that will be allocated in memory items_count is an estimation of the maximum number of items to store. seed is a random value used to generate the hash functions.
sourcepub fn new(bitmap_size: usize, items_count: usize) -> Self
pub fn new(bitmap_size: usize, items_count: usize) -> Self
Create a new bloom filter structure. bitmap_size is the size in bytes (not bits) that will be allocated in memory items_count is an estimation of the maximum number of items to store.
sourcepub fn new_for_fp_rate(items_count: usize, fp_p: f64) -> Self
pub fn new_for_fp_rate(items_count: usize, fp_p: f64) -> Self
Create a new bloom filter structure. items_count is an estimation of the maximum number of items to store. fp_p is the wanted rate of false positives, in ]0.0, 1.0[
sourcepub fn new_for_fp_rate_with_seed(
items_count: usize,
fp_p: f64,
seed: &[u8; 32],
) -> Self
pub fn new_for_fp_rate_with_seed( items_count: usize, fp_p: f64, seed: &[u8; 32], ) -> Self
Create a new bloom filter structure. items_count is an estimation of the maximum number of items to store. fp_p is the wanted rate of false positives, in ]0.0, 1.0[
sourcepub fn from_bit_vec(
bit_vec: BitVec,
bitmap_bits: u64,
k_num: u32,
sip_keys: [(u64, u64); 2],
) -> Self
pub fn from_bit_vec( bit_vec: BitVec, bitmap_bits: u64, k_num: u32, sip_keys: [(u64, u64); 2], ) -> Self
Create a bloom filter structure from a previous state given as a
ByteVec
structure. The state is assumed to be retrieved from an
existing bloom filter.
sourcepub fn from_existing(
bytes: &[u8],
bitmap_bits: u64,
k_num: u32,
sip_keys: [(u64, u64); 2],
) -> Self
pub fn from_existing( bytes: &[u8], bitmap_bits: u64, k_num: u32, sip_keys: [(u64, u64); 2], ) -> Self
Create a bloom filter structure with an existing state given as a byte array. The state is assumed to be retrieved from an existing bloom filter.
sourcepub fn compute_bitmap_size(items_count: usize, fp_p: f64) -> usize
pub fn compute_bitmap_size(items_count: usize, fp_p: f64) -> usize
Compute a recommended bitmap size for items_count items and a fp_p rate of false positives. fp_p obviously has to be within the ]0.0, 1.0[ range.
sourcepub fn check(&self, item: &T) -> boolwhere
T: Hash,
pub fn check(&self, item: &T) -> boolwhere
T: Hash,
Check if an item is present in the set. There can be false positives, but no false negatives.
sourcepub fn check_and_set(&mut self, item: &T) -> boolwhere
T: Hash,
pub fn check_and_set(&mut self, item: &T) -> boolwhere
T: Hash,
Record the presence of an item in the set, and return the previous state of this item.
sourcepub fn number_of_bits(&self) -> u64
pub fn number_of_bits(&self) -> u64
Return the number of bits in the filter
sourcepub fn number_of_hash_functions(&self) -> u32
pub fn number_of_hash_functions(&self) -> u32
Return the number of hash functions used for check
and set
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Bloom<T>where
T: ?Sized,
impl<T> RefUnwindSafe for Bloom<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Send for Bloom<T>
impl<T> Sync for Bloom<T>
impl<T> Unpin for Bloom<T>
impl<T> UnwindSafe for Bloom<T>where
T: UnwindSafe + ?Sized,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)