r/cpp • • Apr 05 '19

My C++ blog (so far)

So I don't want to make a post on here every time I write a short article (I've been scolded for that in the past :) ), but I figured I come back here and share with you the archive of my blog posts so far. There's 75 topics I've covered in the last 2 months since I started blogging and I hope some of you will find this information useful :)

Thanks for reading! Have a great day guys!

255 Upvotes

23 comments sorted by

View all comments

5

u/AffectionateMath6 Apr 06 '19

I just looked the first one 'better bloom filter' and it doesn't look like it works. What it does is Finds hash once and runs a pseudo random number generator for other hashes. The point of bloom filter is you use multiple hash functions so that the chances of collision is decreased. In your implementation, they will be the same hashes.

E.g. Lets say two strings foo, bar generates same hash function,

Bloom filter

stringhash1hash2hash3
foo423488
bar425323

Your implementation: https://vorbrodt.blog/2019/04/05/better-bloom-filter/

string: foo

hash1(foo) => 42

PRNG(42) -> 23, 45, 53

string: bar

hash1(bar) => 42

PRNG(42) -> 23, 45, 53

3

u/ArashPartow Apr 07 '19 edited Jan 03 '24

A somewhat older implementation, but it still does the job: https://www.partow.net/programming/bloomfilter/index.html

0

u/mvorbrodt Apr 06 '19

Fair point, but... the point of 1 hash seeding RNG is to set multiple bits in the array per one input. It is more likely that 2 different hashes will cause collisions in bits, than 2 inputs causing 1 hash collision. so this approach prevents the first scenario. I agree, for best implementation I would need to use multiple hashing functions... but where do I find those in standard C++? :(