Index: Source/wtf/HashFunctions.h |
diff --git a/Source/wtf/HashFunctions.h b/Source/wtf/HashFunctions.h |
index 522bfd776bb8814e37d6574b3229618097048ef9..20bedcd91b6ead4138f9c31012198dfbdba4287a 100644 |
--- a/Source/wtf/HashFunctions.h |
+++ b/Source/wtf/HashFunctions.h |
@@ -37,68 +37,19 @@ namespace WTF { |
// integer hash function |
// Thomas Wang's 32 Bit Mix Function: http://www.cris.com/~Ttwang/tech/inthash.htm |
- inline unsigned intHash(uint8_t key8) |
- { |
- unsigned key = key8; |
- key += ~(key << 15); |
- key ^= (key >> 10); |
- key += (key << 3); |
- key ^= (key >> 6); |
- key += ~(key << 11); |
- key ^= (key >> 16); |
- return key; |
- } |
+ unsigned intHash(uint8_t key8); |
// Thomas Wang's 32 Bit Mix Function: http://www.cris.com/~Ttwang/tech/inthash.htm |
- inline unsigned intHash(uint16_t key16) |
- { |
- unsigned key = key16; |
- key += ~(key << 15); |
- key ^= (key >> 10); |
- key += (key << 3); |
- key ^= (key >> 6); |
- key += ~(key << 11); |
- key ^= (key >> 16); |
- return key; |
- } |
+ unsigned intHash(uint16_t key16); |
// Thomas Wang's 32 Bit Mix Function: http://www.cris.com/~Ttwang/tech/inthash.htm |
- inline unsigned intHash(uint32_t key) |
- { |
- key += ~(key << 15); |
- key ^= (key >> 10); |
- key += (key << 3); |
- key ^= (key >> 6); |
- key += ~(key << 11); |
- key ^= (key >> 16); |
- return key; |
- } |
+ unsigned intHash(uint32_t key); |
// Thomas Wang's 64 bit Mix Function: http://www.cris.com/~Ttwang/tech/inthash.htm |
- inline unsigned intHash(uint64_t key) |
- { |
- key += ~(key << 32); |
- key ^= (key >> 22); |
- key += ~(key << 13); |
- key ^= (key >> 8); |
- key += (key << 3); |
- key ^= (key >> 15); |
- key += ~(key << 27); |
- key ^= (key >> 31); |
- return static_cast<unsigned>(key); |
- } |
+ unsigned intHash(uint64_t key); |
// Compound integer hash method: http://opendatastructures.org/versions/edition-0.1d/ods-java/node33.html#SECTION00832000000000000000 |
- inline unsigned pairIntHash(unsigned key1, unsigned key2) |
- { |
- unsigned shortRandom1 = 277951225; // A random 32-bit value. |
- unsigned shortRandom2 = 95187966; // A random 32-bit value. |
- uint64_t longRandom = 19248658165952622LL; // A random 64-bit value. |
- |
- uint64_t product = longRandom * (shortRandom1 * key1 + shortRandom2 * key2); |
- unsigned highBits = static_cast<unsigned>(product >> (sizeof(uint64_t) - sizeof(unsigned))); |
- return highBits; |
- } |
+ unsigned pairIntHash(unsigned key1, unsigned key2); |
template<typename T> struct IntHash { |
static unsigned hash(T key) { return intHash(static_cast<typename IntTypes<sizeof(T)>::UnsignedType>(key)); } |