Boost logo

Boost :

Subject: Re: [boost] [hash] regular behaviour of hash function for double values
From: Daniel James (dnljms_at_[hidden])
Date: 2012-01-31 13:55:21


On 31 January 2012 17:57, Andrey Semashev <andrey.semashev_at_[hidden]> wrote:
> On Tuesday, January 31, 2012 18:33:25 Thomas Klimpel wrote:
>>
>> > but my understanding is that it's the hash function's job.
>>
>> What do you mean by "my understanding"? Your understanding of the standard,
>> or your understanding of the best solution, or your understanding of that
>> conversation? You also advocated your "understanding" during that
>> conversation.
>
> The standard doesn't favor or preclude either approach, so either way the
> implementation would be conforming. So, you might say it's my understanding of
> both the standard and the "best" solution. I realize that my opponent had a
> different opinion on this and I didn't convince him.

The requirements for the hash function are:

For two different values
t1 and t2, the probability that h(t1) and h(t2) compare
equal should be very small, approaching 1.0 / numeric_-
limits<size_t>::max().

There's no requirement about how h(t1) and h(t2) are distributed so it
must be the container's responsibility, since the container must work
well with any hash function that meets these requirements. How else
can you interpret it?


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