Boost logo

Boost :

Subject: Re: [boost] [optional] operator<(optional<T>, T) -- is it wrong?
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2014-12-02 19:35:44

On 2 Dec 2014 at 23:26, Stephan T. Lavavej wrote:

> > I don't see why eg. std::hash<size_t> (or any smaller type)
> > doesn't just return the bitwise equivalent of the original value by
> > default, as this has zero collision probability and the highest performance.
> Hashes are typically masked to get bucket indices, so hashing integers
> with the identity function allows collisions to be trivially generated,
> either intentionally or unintentionally. For example, 0x1000, 0x2000,
> 0x3000, 0x4000 are highly likely to collide, if the lower bits are being
> used to index buckets.

There are other big problems with trivial hashes too in that certain
unfortunately common choices of bucket size happen to generate
resonances with unfortunately common trivial hashes.

I was tempted in concurrent_unordered_map to detect trivial hashes
and deliberately subvert known terrible combinations of bucket size
and trivial hashes by twiddling the bucket count away from what was
requested, but then I remembered I am not a statistician.


ned Productions Limited Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at