Crates.io | frbf |
lib.rs | frbf |
version | 0.1.0 |
source | src |
created_at | 2023-10-08 09:42:15.597137 |
updated_at | 2023-10-08 09:42:15.597137 |
description | A simple, robust, and efficient implementation of the Bloom Filter data structure in Rust. |
homepage | |
repository | |
max_upload_size | |
id | 997034 |
size | 9,238 |
A simple, robust, and efficient implementation of the Bloom Filter data structure in Rust.
A Bloom Filter is a probabilistic data structure that can test whether an element is a member of a set. It returns either "possibly in the set" or "definitely not in the set". False positive matches are possible, but false negatives are not.
To create a new Bloom Filter:
let bloom_filter_result = BloomFilter::new(1000, 0.01);
match bloom_filter_result {
Ok(mut bloom_filter) => {
// Use the bloom filter...
},
Err(e) => {
println!("Error creating Bloom Filter: {}", e);
}
}
This attempts to create a new Bloom Filter optimized for 1000 items and a 1% false positive probability. Make sure to handle the potential errors.
To add an item to the Bloom Filter:
bloom_filter.add(&"hello");
To check if an item is present in the Bloom Filter:
if bloom_filter.check(&"hello") {
println!("'hello' might be in the set!");
} else {
println!("'hello' is definitely not in the set.");
}