Commit d01eee95 authored by Davis King's avatar Davis King

Added murmur_hash3_3()

parent 49f2d6f9
......@@ -255,6 +255,53 @@ namespace dlib
return h1;
}
// ----------------------------------------------------------------------------------------
inline uint32 murmur_hash3_3 (
const uint32 v1,
const uint32 v2,
const uint32 v3
)
{
uint32 h1 = v3;
uint32 c1 = 0xcc9e2d51;
uint32 c2 = 0x1b873593;
//----------
// body
uint32 k1 = v1;
k1 *= c1;
k1 = DLIB_ROTL32(k1,15);
k1 *= c2;
h1 ^= k1;
h1 = DLIB_ROTL32(h1,13);
h1 = h1*5+0xe6546b64;
k1 = v2;
k1 *= c1;
k1 = DLIB_ROTL32(k1,15);
k1 *= c2;
h1 ^= k1;
h1 = DLIB_ROTL32(h1,13);
h1 = h1*5+0xe6546b64;
//----------
// finalization
h1 ^= 8; // =^ by length in bytes
h1 = murmur_fmix(h1);
return h1;
}
// ----------------------------------------------------------------------------------------
inline std::pair<uint64,uint64> murmur_hash3_128bit (
......
......@@ -44,6 +44,22 @@ namespace dlib
See: http://code.google.com/p/smhasher/
!*/
// ----------------------------------------------------------------------------------------
inline uint32 murmur_hash3_3 (
const uint32 v1,
const uint32 v2,
const uint32 v3
);
/*!
ensures
- returns a 32bit hash of the three integers given to this function.
- This function is machine architecture agnostic and should always give the same
hash value when presented with the same inputs.
- This hashing algorithm is Austin Appleby's excellent MurmurHash3_x86_32.
See: http://code.google.com/p/smhasher/
!*/
// ----------------------------------------------------------------------------------------
std::pair<uint64,uint64> murmur_hash3_128bit (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment