hash_utils::MurmurHash3 Class Reference

#include <hash.h>

List of all members.

Public Types

typedef const Byte_t * MsgPtr_t
typedef UInt_t Hash_t
typedef Int_t Length_t
typedef Byte_t Rot_t

Public Member Functions

 MurmurHash3 (unsigned int seed=0xe086c5ff)
void Add (MsgPtr_t msg_ptr, Length_t len)
Hash_t End ()

Private Member Functions

void MixTail (MsgPtr_t &data, Length_t &len)
UInt_t rot32 (UInt_t bits, Rot_t r)
void mmix (Hash_t &h, UInt_t &bits)
void final_mix (Hash_t &h)

Private Attributes

Hash_t fHash
UInt_t fTail
UInt_t fCount
UInt_t fSize

Static Private Attributes

static const UInt_t kMply1 = 0xcc9e2d51
static const UInt_t kMply2 = 0x1b873593

Detailed Description

Definition at line 27 of file hash.h.


Member Typedef Documentation

Definition at line 30 of file hash.h.

Definition at line 31 of file hash.h.

typedef const Byte_t* hash_utils::MurmurHash3::MsgPtr_t

Definition at line 29 of file hash.h.

Definition at line 32 of file hash.h.


Constructor & Destructor Documentation

hash_utils::MurmurHash3::MurmurHash3 ( unsigned int  seed = 0xe086c5ff  )  [inline]

Definition at line 34 of file hash.h.

00035     : fHash(seed), fTail(0), fCount(0), fSize(0)
00036   {}


Member Function Documentation

void MurmurHash3::Add ( MsgPtr_t  msg_ptr,
Length_t  len 
)

Definition at line 53 of file hash.cpp.

References fHash, fSize, MixTail(), and mmix().

00054 {
00055   fSize += len;
00056   
00057   while(len >= 4) {
00058     UInt_t k = *(reinterpret_cast<const UInt_t*>(msg_ptr));
00059     mmix(fHash, k);
00060     msg_ptr += 4;
00061     len -= 4;
00062   }
00063   
00064   MixTail(msg_ptr,len);
00065 }

MurmurHash3::Hash_t MurmurHash3::End (  ) 

Definition at line 71 of file hash.cpp.

References fHash, final_mix(), fSize, fTail, and mmix().

00072 {
00073   if (fTail) mmix(fHash, fTail);
00074   fHash ^= fSize;
00075   final_mix(fHash);
00076   return fHash;
00077 }

void hash_utils::MurmurHash3::final_mix ( Hash_t h  )  [inline, private]

Definition at line 55 of file hash.h.

Referenced by End().

00056   {
00057     h ^= h >> 16;   h *= 0x85ebca6b;
00058     h ^= h >> 13;   h *= 0xc2b2ae35;
00059     h ^= h >> 16;
00060   }

void MurmurHash3::MixTail ( MsgPtr_t data,
Length_t len 
) [private]

Definition at line 83 of file hash.cpp.

References fCount, fHash, fTail, and mmix().

Referenced by Add().

00084 {
00085   while( len && ((len<4) || fCount)) {
00086     fTail |= (*data++) << (fCount * 8);
00087     fCount++;
00088     len--;
00089     
00090     if(fCount == 4){
00091       mmix(fHash, fTail);
00092       fTail = 0;
00093       fCount = 0;
00094     }
00095   }
00096 }

void hash_utils::MurmurHash3::mmix ( Hash_t h,
UInt_t &  bits 
) [inline, private]

Definition at line 49 of file hash.h.

References kMply1, kMply2, and rot32().

Referenced by Add(), End(), and MixTail().

00050   { 
00051     bits *= kMply1;   bits = rot32(bits, 15);   bits *= kMply2;
00052     h ^= bits;   h = rot32(h, 13) * 5 + 0xe6546b64;
00053   }

UInt_t hash_utils::MurmurHash3::rot32 ( UInt_t  bits,
Rot_t  r 
) [inline, private]

Definition at line 44 of file hash.h.

Referenced by mmix().

00045   {
00046     return (bits << r) | (bits >> (32 - r));
00047   }


Member Data Documentation

Definition at line 72 of file hash.h.

Referenced by MixTail().

Definition at line 70 of file hash.h.

Referenced by Add(), End(), and MixTail().

Definition at line 73 of file hash.h.

Referenced by Add(), and End().

Definition at line 71 of file hash.h.

Referenced by End(), and MixTail().

const UInt_t hash_utils::MurmurHash3::kMply1 = 0xcc9e2d51 [static, private]

Definition at line 62 of file hash.h.

Referenced by mmix().

const UInt_t hash_utils::MurmurHash3::kMply2 = 0x1b873593 [static, private]

Definition at line 63 of file hash.h.

Referenced by mmix().


The documentation for this class was generated from the following files:

Generated on 15 Jun 2016 for AlcapDAQ by  doxygen 1.6.1