Subject: Re: [boost] [functional/hash] integer hash function
From: Tim Blechmann (tim_at_[hidden])
Date: 2011-10-05 04:31:53


> The distribution of the input is irrelevant. It's always mirrored in the
> distribution of the output (regardless of the hash function, as long as
> there are no collisions) because there is 1:1 correspondence between the
> input and output values. The problem arises when output bits are discarded.
> In the pathological case, if the input is 0..31 and one discards the bottom
> 5 bits, the result is always 0. But the default hash function can't know
> that you're going to discard bits, or how to fix that for you.

fwiw, there are algorithms like knuth's multiplicative hash, which are almost
as fast as a trivial hash function, but provide at least a certain degree of
hash distribution ...

this is what i'm now using for my use case

tim