Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-03-16 13:03:41


Dave Harris wrote:
> In-Reply-To: <001001c529b2$4841da80$6501a8c0_at_pdimov2>
> pdimov_at_[hidden] (Peter Dimov) wrote (abridged):
>> Alignment is only going to be a problem if the lower sizeof(size_t) *
>> CHAR_BIT bits of the value produced by reinterpret_cast do not
>> contain enough entropy. I think that in practice the hash function
>> will be good enough.
>
> It partly depends on how the hash_value is used. If the value is
> always a multiple of 8, say, and it is used with a bucket count which
> is a power of 2, then only 1 out of every 8 buckets will get used.
> Entropy in the higher bits doesn't help.
>
> You may be assuming that no-one will use a bucket count which is not a
> prime number. I'd rather not make that assumption if we can reasonably
> avoid it.

This is not an assumption. It is the specification of hash_value that
determines how it is to be used. Currently it does not offer any guarantees
for the entropy of any particular bits, so the client of hash_value is
expected to not do something stupid, like throw away 28 of its 32 bits.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk