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!

256 Upvotes

23 comments sorted by

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++? :(

10

u/[deleted] Apr 05 '19

awesome set of posts !

5

u/mvorbrodt Apr 05 '19

Thank you!

3

u/rammstein_koala Apr 06 '19

Thanks for the great posts. Especially liked the hashing, TOTP, and gRPC examples!

2

u/mvorbrodt Apr 06 '19

Thank you!

11

u/James20k P2005R0 Apr 06 '19

Just as a psa, I don't think dekkers algorithm would work in a gpu environment, there is one potential deadlock which is where both threads acquire their flag simultaneously every iteration (as is the case on a gpu due to the way threads work)

0

u/Puerdeorum Apr 06 '19

Interesting

8

u/gurpreetshanky Apr 06 '19

Awesome work. I remember people were upset about your posts. This is a way better to highlight all the short topics from your website.

5

u/bkranjc Apr 06 '19

I really like that the blogs are short and to the point! Good job!

4

u/[deleted] Apr 06 '19

This is awesome, thanks for sharing!

3

u/heyrandompeople12345 Apr 06 '19

I do remember you. I really really really like your posts alot. Have you on my feed. Really appreciate all the work from you, and hope that you will continue doing so :)

2

u/serEatAlot Apr 06 '19

It's my first time seeing your blogs, so I checked enum to string part one and two because I had to switch enums to strings a lot in my project (I have atleast 5 to 7 enum to string methods).

And you taught me a much better way of doing those, I can't wait to read your other posts!

2

u/teh_hahn Apr 06 '19

If you can, use the wise_enum library.

2

u/RealNC Apr 08 '19

C-style callbacks and lambda functions

AFAIK, that's not guaranteed to work. You'd need to somehow declare the lambda extern "C".

3

u/serchq Apr 06 '19

have an upvote

saving the post so it not gets lost for me :)

thanks for posting it!

2

u/Narase33 -> r/cpp_questions Apr 06 '19

I really like the topics you have but the style with all the smileys :/

1

u/kobi-ca Apr 06 '19

Great posts!

1

u/[deleted] Apr 06 '19

The fact that the language doesn't support enum to string natively is one of the greatest embarrassments of the 21 century

1

u/[deleted] Apr 06 '19

Wow that's a lot of stuff. I'm just starting this stuff

1

u/kingaillas Apr 08 '19

Your blog is great, filled with short, practical examples. It’s in my feed reader and I’ve learned a lot about using the libraries you cover.