Struct fastbloom_rs::BloomFilter
source · [−]pub struct BloomFilter { /* private fields */ }Implementations
sourceimpl BloomFilter
impl BloomFilter
sourcepub fn new(config: FilterBuilder) -> Self
pub fn new(config: FilterBuilder) -> Self
Build a Bloom filter form FilterBuilder.
Examples:
use fastbloom_rs::{BloomFilter, FilterBuilder};
let builder = FilterBuilder::new(100_000_000, 0.01);
let bloom = BloomFilter::new(builder);sourcepub fn from_bit_vec(bit_vec: &BitVec, hashes: u32) -> Self
pub fn from_bit_vec(bit_vec: &BitVec, hashes: u32) -> Self
sourcepub fn from_u32_array(array: &[u32], hashes: u32) -> Self
pub fn from_u32_array(array: &[u32], hashes: u32) -> Self
Build a Bloom filter form [&[u32]].
Examples
use bit_vec::BitVec;
use fastbloom_rs::BloomFilter;
let mut array = Vec::with_capacity(4096);
unsafe {array.set_len(4096); array.fill(0u32);};
let bloom = BloomFilter::from_u32_array(array.as_slice(), 4);sourcepub fn config(&self) -> FilterBuilder
pub fn config(&self) -> FilterBuilder
Returns the configuration/builder of the Bloom filter.
Examples
use fastbloom_rs::{BloomFilter, FilterBuilder};
let bloom = FilterBuilder::new(100_000_000, 0.01).build_bloom_filter();
let builder = bloom.config();sourcepub fn contains(&self, element: &[u8]) -> bool
pub fn contains(&self, element: &[u8]) -> bool
Tests whether an element is present in the filter (subject to the specified false positive rate).
pub fn get(&self, index: usize) -> Option<bool>
pub fn set(&mut self, index: usize, to: bool)
sourcepub fn get_bit_vec(&self) -> BitVec
pub fn get_bit_vec(&self) -> BitVec
Return the underlying bit vector of the Bloom filter.
sourcepub fn get_u8_array(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn get_u8_array(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Return the underlying byte vector of the Bloom filter.
sourcepub fn get_u32_array(&self) -> &[u32]
pub fn get_u32_array(&self) -> &[u32]
Return the underlying u32 vector of the Bloom filter.
sourcepub fn union(&mut self, other: &BloomFilter) -> bool
pub fn union(&mut self, other: &BloomFilter) -> bool
Performs the union operation on two compatible bloom filters. This is achieved through a bitwise OR operation on their bit vectors. This operations is lossless, i.e. no elements are lost and the bloom filter is the same that would have resulted if all elements wer directly inserted in just one bloom filter.
sourcepub fn intersect(&mut self, other: &BloomFilter) -> bool
pub fn intersect(&mut self, other: &BloomFilter) -> bool
Performs the intersection operation on two compatible bloom filters. This is achieved through a bitwise AND operation on their bit vectors. The operations doesn’t introduce any false negatives but it does raise the false positive probability. The the false positive probability in the resulting Bloom filter is at most the false-positive probability in one of the constituent bloom filters
pub fn set_bit_vec(&mut self, bit_vec: BitVec)
Trait Implementations
sourceimpl Clone for BloomFilter
impl Clone for BloomFilter
sourcefn clone(&self) -> BloomFilter
fn clone(&self) -> BloomFilter
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
Auto Trait Implementations
impl RefUnwindSafe for BloomFilter
impl Send for BloomFilter
impl Sync for BloomFilter
impl Unpin for BloomFilter
impl UnwindSafe for BloomFilter
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more