[−][src]Struct plum::StandardBloomFilter
A fast standard Bloom Filter implementation that requires only two
hash functions, generated by std::collections::hash_map::DefaultHasher
.
If an item is not present in the filter then contains
is guaranteed
to return false
for the queried item.
The probability that contains
returns true
for an item that is not
present in the filter is called the False Positive Rate.
Example Usage
use plum::StandardBloomFilter; let items_count = 1_000_000; let fp_rate = 0.01; let mut bloom = StandardBloomFilter::new(items_count, fp_rate); bloom.insert("item1"); bloom.contains("item1"); /* true */ bloom.contains("item2"); /* false */
Implementations
impl<T: ?Sized> StandardBloomFilter<T>
[src]
pub fn new(items_count: usize, fp_rate: f64) -> Self
[src]
Create a new StandardBloomFilter that expects to store items_count
membership with a false positive rate of the value specified in fp_rate
.
pub fn insert(&mut self, item: &T) where
T: Hash,
[src]
T: Hash,
Insert item to the set.
pub fn contains(&mut self, item: &T) -> bool where
T: Hash,
[src]
T: Hash,
Check if an item is present in the set. There can be false positives, but no false negatives.
Auto Trait Implementations
impl<T: ?Sized> RefUnwindSafe for StandardBloomFilter<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T: ?Sized> Send for StandardBloomFilter<T> where
T: Send,
T: Send,
impl<T: ?Sized> Sync for StandardBloomFilter<T> where
T: Sync,
T: Sync,
impl<T: ?Sized> Unpin for StandardBloomFilter<T> where
T: Unpin,
T: Unpin,
impl<T: ?Sized> UnwindSafe for StandardBloomFilter<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
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> 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>,