Files
bloom-filter.cpp/DEV.md
2026-04-27 15:03:14 +02:00

872 B

Dev Docs

I've scaffolded but it I feel it makes more sense to just have a one file impl first in some .cpp file and take it from there. So off we go to top level main.cpp

There is an original paper but I'm reading off from wiki for now https://en.wikipedia.org/wiki/Bloom_filter

Making k hashes

This was the first problem. Just like open addressing hash tables do it.

Idea is you take 2 hash functions and then use them as

h_i(x) = ( h1(x) + i.h2(x) ) mod m

Then if I say that gcd(h2(x),m) = 1 then thi will loop over all residues and I have a uniform spread over the range m.

I can't do h(x) + i as that's a bad idea since it'll be consecutive same with i . h(x) as there will be just equally spaced strides.

This double hashed func almost behaves like a random number generator.

std::hash

you make a hasher object and them immediately call it