# ๐งน broomfilter ๐งน
> *Sweeping away your certainty, one hash at a time.*
A bloom filter implementation in Rust. Named `broomfilter` because it sweeps
through your data and tells you "yeah, *probably*" with the confidence of someone
who definitely didn't study for the exam.
---
## ๐ค What is this?
A bloom filter is a probabilistic data structure that can tell you:
- โ **"Definitely not in the set"** โ 100% accurate, take it to the bank
- ๐คท **"Probably in the set"** โ maybe, who knows, trust issues
Think of it as that friend who says "I'm *pretty sure* I locked the door."
You can trust them when they say they didn't, but when they say they did...
you might want to go check.
### ๐งน How the broom sweeps
```
item โโโ [ hash hash hash ] โโโ flip bits in the array
๐งน๐จ
query โโโ [ hash hash hash ] โโโ check bits
โโโ all set? โ "probably yes" ๐คท
โโโ any unset? โ "definitely no" โ
```
---
## ๐ก Why does this exist?
Because I wanted to learn what a bloom filter actually is instead of just
nodding along when someone mentions one in a meeting. Turns out it's a big
array of bits and some hashing. Who knew? (Everyone. Everyone knew.) ๐งน
---
## ๐ Usage
```rust
use broomfilter::Filter;
// Create a filter with 2^14 bits, optimized for 10,000 items
let mut filter = Filter::new(14, 10_000).unwrap();
// Insert some things ๐งน
filter.insert("hello");
filter.insert("world");
// Check for things
assert!(filter.contains("hello")); // true โ probably ๐คท
assert!(!filter.contains("goodbye")); // false โ definitely โ
```
---
## ๐๏ธ Status
> โ ๏ธ **Work in progress** โ handle with care (or don't, I'm a README not a cop)
It works, it has benchmarks, it *probably* won't eat your data. But then again,
the whole point of a bloom filter is that you can never be 100% sure about anything.
| Insert items | โ
Swept in |
| Check membership | โ
Probably |
| False positives | โ
It's a feature |
| False negatives | ๐ซ Impossible (finally, some certainty) |
| Delete items | ๐งน Nope, the broom only sweeps one way |
---
## ๐ License
MIT โ do whatever you want with it, just don't blame me when
`contains()` lies to you. That's a feature, not a bug. ๐งน