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 15:57:11

On 31 January 2012 20:31, Christopher Jefferson <chris_at_[hidden]> wrote:
> On 31 Jan 2012, at 19:58, Daniel James wrote:
>> On 31 January 2012 16:19, Kai Schroeder <kaischroeder3_at_[hidden]> wrote:
>>> Well, I tend
>>> to agree that this is a bug in TBB
>> I actually don't. If TBB requires a better quality hash function, then
>> that's fine. I also wouldn't use boost::hash or std::hash with
>> google's hash tables.
> It would be easy to provide a boost::hash_shuffle, that could be applied to any boost::hash and provide this stronger requirement (that there is no corrolation between (a-b) and (hash(a)-hash(b)). This would avoid the need to re-write all the existing hash functions.

Feel free to do so. Although, I'd probably write it to use better
algorithms where possible, and just use boost::hash as a fallback for
when they're not. I think I've mentioned before that I regret calling
it 'boost::hash', 'boost::functional::hash' would have been a better

Btw. to go back to the original post, I might change the mix function
for floats, it might be problematic as it is. Also, the float hash is
actually a bit slow because it's doesn't rely on the binary
representation of floating point numbers. But when the binary
representation is known to be safely hashable, it might be better to
hash that. I already do that for cygwin because the floating point
functions weren't available there. The problem is accounting for the
different representations, which I don't want to spend too much time
dealing with.

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