29 #ifndef _3ESVECTORHASH_H 30 #define _3ESVECTORHASH_H 34 #include <unordered_map> 37 #define VHASH_MAGIC (0x9e3779b9u) 40 #define VHASH_JENKINS_MIX(a, b, c) \ 41 a -= b; a -= c; a ^= (c>>13); \ 42 b -= c; b -= a; b ^= (a<<8); \ 43 c -= a; c -= b; c ^= (b>>13); \ 44 a -= b; a -= c; a ^= (c>>12); \ 45 b -= c; b -= a; b ^= (a<<16); \ 46 c -= a; c -= b; c ^= (b>>5); \ 47 a -= b; a -= c; a ^= (c>>3); \ 48 b -= c; b -= a; b ^= (a<<10); \ 49 c -= a; c -= b; c ^= (b>>15); 63 inline uint32_t
hashBits(uint32_t a, uint32_t b = VHASH_MAGIC, uint32_t c = 0)
66 VHASH_JENKINS_MIX(a, b, c);
78 inline uint32_t
hashBits(uint32_t a, uint32_t b, uint32_t c, uint32_t d, uint32_t e = 0, uint32_t f = 0)
81 VHASH_JENKINS_MIX(a, b, c);
85 VHASH_JENKINS_MIX(a, b, c);
94 inline uint32_t
hash(
float x,
float y,
float z)
96 return hashBits(*(
const uint32_t *)&x, *(
const uint32_t *)&y, *(
const uint32_t *)&z);
105 inline uint32_t
hash(
float x,
float y,
float z,
float w)
107 return hashBits(*(
const uint32_t *)&x, *(
const uint32_t *)&y, *(
const uint32_t *)&z, *(
const uint32_t *)&w);
128 #endif // _3ESVECTORHASH_H uint32_t hashBits(uint32_t a, uint32_t b=VHASH_MAGIC, uint32_t c=0)
Generate a hash for 2 to 3 components.
Definition: 3esvectorhash.h:63
Hash structure for use with standard library maps.
Definition: 3esvectorhash.h:115
Definition: 3esbounds.h:13
uint32_t hash(float x, float y, float z)
Generate a hash code for a 3-component vertex.
Definition: 3esvectorhash.h:94
size_t operator()(const T &p) const
Operator to convert the vector p to its hash code.
Definition: 3esvectorhash.h:121