-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement ContainerHash: a simple hashing structure for containers #324
Conversation
ContainerHash is a simple hashing algorithm for containers, based on the Boost implementation. It is useful for cases where a container is needed as a key in a hash-dependant container, such as a set or an unordered_map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Needs tests?
A span is to an array what a string_view is to a string. Basically, it is a lightweight and fast non-owning way to pass arrays around while conserving their length. Right now, we are using span-lite, an implementation of std::span, since the later one will be available in C++20
Also, added tests for it.
This will dramatically reduce the number of collisions.
This test uses template metaprogramming* to test BitSets of different length. In the future, it would be a good idea to update the rest of the tests to make use of this technique too. * in particular, integer sequences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Almost there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pull request adds a useful utility to hash any container with a begin/end while fixing a cavalcade of existing bugs/shortcomings that were unearthed along the way.
ContainerHash utilizes hash_combine to assign a unique hash to a container, allowing their use in sets and unordered_map keys.