|
Boost : |
From: Caleb Epstein (caleb.epstein_at_[hidden])
Date: 2005-03-15 11:51:16
On Tue, 15 Mar 2005 16:20 +0000 (GMT), Dave Harris
<brangdon_at_[hidden]> wrote:
> Another is to allow treating of 32-bit values as bytes. For example,
>
> size_t hash_range( const int *first, const int *last ) {
> return hash_range(
> static_cast<const unsigned char *>(first),
> static_cast<const unsigned char *>(last) );
> }
>
> may be a good implementation on some platforms. It does 4 times as many
> mixing steps (assuming sizeof(int) == 4) as the proposed algorithm. It is,
> I think, how the designer of the proposed hash_combine algorithm expected
> it to be used.
>
> However, it yields hash values for int * different to the values for char
> *, so with the current design aims we can't use it.
It also has the undesirable side-effect of making the hash value
depend on the machine endianness. The same set of integers would hash
to different values on (say) Sparc and Intel machines.
-- Caleb Epstein caleb dot epstein at gmail dot com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk