
4 Oct
2011
4 Oct
'11
10:19 p.m.
On 10/04/2011 10:03 PM, Tim Blechmann wrote:
i was quite amazed that the default hash function for integers seems to be the identity function:
from boost/functional/hash/hash.hpp: inline std::size_t hash_value(int v) { return static_cast<std::size_t>(v); }
while this is probably the most efficient hash function, it is also the worst possible. is this done intentionally?
It's only bad if you know your possible values are not equally distributed over the whole range of "int". Which is not something a default hashing function can know.