
On Tue, 15 Mar 2005 16:20 +0000 (GMT), Dave Harris <brangdon@cix.compulink.co.uk> 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