Use the BloomFilter API
mainThe BloomFilter can be instantiated by specifying the number of bits or a target false positive rate. You can then insert items or initialize the filter with an iterator of items.
Basic initialization with bit count
let mut filter = BloomFilter::with_num_bits(1024).expected_items(2);
filter.insert("42");Initialization with target false positive rate
let filter = BloomFilter::with_false_pos(0.001).items(["42", "🦀"].iter());
assert!(filter.contains("42"));Using a custom hasher
fastbloom is compatible with any hasher. You can configure it using the .hasher() method.
let filter = BloomFilter::with_num_bits(1024)
.hasher(RandomState::default())
.items(["42", "🦀"].iter());use fastbloom::BloomFilter;
let mut filter = BloomFilter::with_num_bits(1024).expected_items(2);
filter.insert("42");
filter.insert("🦀");