TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
HashTrait< G3D::uint128 > Struct Template Reference

#include <HashTrait.h>

Static Public Member Functions

static size_t hashCode (G3D::uint128 key)
 

Member Function Documentation

static size_t HashTrait< G3D::uint128 >::hashCode ( G3D::uint128  key)
inlinestatic
162  {
163  return G3D::superFastHash(&key, sizeof(key));
164  //return HashTrait<G3D::uint64>::hashCode(key.hi) ^ HashTrait<G3D::uint64>::hashCode(key.lo);
165 
166 #if 0 // Really slow under gcc
167  // Use the FNV-1 hash (http://isthe.com/chongo/tech/comp/fnv/#FNV-1).
168  static const G3D::uint128 FNV_PRIME_128(1 << 24, 0x159);
169  static const G3D::uint128 FNV_OFFSET_128(0xCF470AAC6CB293D2ULL, 0xF52F88BF32307F8FULL);
170 
171  G3D::uint128 hash = FNV_OFFSET_128;
172  G3D::uint128 mask(0, 0xFF);
173  for (int i = 0; i < 16; ++i) {
174  hash *= FNV_PRIME_128;
175  hash ^= (mask & key);
176  key >>= 8;
177  }
178 
179  G3D::uint64 foldedHash = hash.hi ^ hash.lo;
180  return static_cast<size_t>((foldedHash >> 32) ^ (foldedHash & 0xFFFFFFFF));
181 #endif
182  }
#define hash
Definition: private_namespace.h:186
G3D::uint64 hi
Definition: uint128.h:23
uint32_t superFastHash(const void *_data, size_t numBytes)
A hash function that is faster than CRC32 for arbitrary long strings http://www.azillionmonkeys.com/qed/hash.html by Paul Hsieh.
Definition: HashTrait.h:35
uint64_t uint64
Definition: g3dmath.h:170
Definition: uint128.h:20
G3D::uint64 lo
Definition: uint128.h:24

+ Here is the call graph for this function:


The documentation for this struct was generated from the following file: