Hacker News new | past | comments | ask | show | jobs | submit login

Why using a good or better hash table, when you can implement the worst by yourself? OMG



Well these things are what everyone has to do in college anyway because it's helpful for training you. And if you didn't get to do that in your algo courses or you didn't do college or haven't done it yet then articles like this are super useful.


> Solving it helped me gain better intuition around hash functions, pointers, and memory segments like the stack and the heap.


Can you at least list some good or better hash tables?


search for htable or hashtable in thousands of open source projects. only a minority has worse hashtables than this one (clisp, perl5 e.g.).

For better ones I would point to my linked list implementation: https://github.com/rurban/ctl/blob/master/ctl/unordered_set.... (because it has various security policies, nobody else has) or https://github.com/LIMachi/swiss-table (all in C)


Having Swiss Tables (a more or less state of the art hash table for modern computers) is attractive but I think it'd be appropriate to be scared of unmaintained C labelled as a "proof of concept".

The CTL "unordered set" is roughly the same bad design as its namesake in C++, presumably on purpose. We really shouldn't be teaching new users this bad structure, nor the "security policy" mitigations it provides. And by the way it's not a "distributed" denial of service when somebody plugs 128 colliding values into your API, just a normal trivial DOS.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: