ATLAS Offline Software
|
Improved hash function for pointers. More...
#include <ptrhash.h>
Public Member Functions | |
std::size_t | operator() (const void *p) const |
Improved hash function for pointers.
The default hash function for pointers used by unordered_map
and friends is just the result of casting the pointer to an int. The problem is that most pointers one deals with are going to be aligned; if the pointers are to objects obtained through malloc, then on all systems we deal with, at least the lower three bits of the pointer will always be clear. Since unordered_map
uses a bucket-hash scheme, this means that only 1/8 of the buckets will be used in such a case, resulting in lower efficiency.
Here, we try to avoid this problem.
|
inline |