1 unstable release
0.1.0 | Feb 14, 2022 |
---|
#8 in #spectral
22KB
302 lines
generic-bloom
This crate provides a BloomFilter
trait which can be parameterized
by different types of storage (via the BloomSet
trait) to obtain
traditional binary Bloom filters, counting Bloom filters, and spectral
Bloom filters. For more information, see the
documentation.
lib.rs
:
This crate provides a BloomFilter
trait which can be
parameterized by different types of storage (via the BloomSet
trait) to obtain traditional binary Bloom filters, counting Bloom
filters, and spectral Bloom filters. For basic usage, see the
documentation for SimpleBloomFilter
.
BloomSet
implementations are provided for
BitBox
es (for traditional bitmap-style
Bloom filters) and Box<[T]>
where T
is a numeric type (for
counting or spectral Bloom filters).
Example
Basic usage:
use generic_bloom::{BloomFilter, SimpleBloomFilter};
use bitvec::prelude::*;
let mut filter: SimpleBloomFilter<BitBox<usize, Lsb0>> = SimpleBloomFilter::new(10, 20);
filter.insert(&48);
filter.insert(&32);
assert!(filter.contains(&48));
assert!(filter.contains(&32));
// May fail if 39 happens to be a false positive
assert!(!filter.contains(&39));
Dependencies
~1MB
~25K SLoC