hash_utils::murmurhash2 Struct Reference

#include <hash.h>

List of all members.

Public Member Functions

 murmurhash2 (UInt_t seed)
UInt_t operator() (const void *key, int len) const

Public Attributes

const UInt_t fSeed

Detailed Description

Functor copy of murmurhash2 (Public Domain / MIT liscence) by Austin Appleby If it's good enoiugh for gcc...

Definition at line 10 of file hash.h.


Constructor & Destructor Documentation

hash_utils::murmurhash2::murmurhash2 ( UInt_t  seed  )  [inline]

Definition at line 11 of file hash.h.

00011 : fSeed(seed) {};


Member Function Documentation

UInt_t hash_utils::murmurhash2::operator() ( const void *  key,
int  len 
) const

Definition at line 4 of file hash.cpp.

References fSeed.

00005 {
00006   // 'm' and 'r' are mixing constants generated offline.
00007   // They're not really 'magic', they just happen to work well.
00008   const UInt_t m = 0x5bd1e995;
00009   const Int_t r = 24;
00010   
00011   // Initialize the hash to a 'random' value
00012   UInt_t h = fSeed ^ len;
00013   
00014   // Mix 4 bytes at a time into the hash
00015   const Byte_t* data = (const Byte_t*) key;
00016   
00017   while(len >= 4){
00018     UInt_t k = *(UInt_t *)data;
00019     
00020     k *= m; 
00021     k ^= k >> r; 
00022     k *= m; 
00023     
00024     h *= m; 
00025     h ^= k;
00026     
00027     data += 4;
00028     len -= 4;
00029   }
00030   
00031   // Handle the last few bytes of the input array 
00032   // fallthrough is intended 
00033   switch(len) {
00034   case 3: h ^= data[2] << 16; 
00035   case 2: h ^= data[1] << 8;
00036   case 1: h ^= data[0];
00037     h *= m;
00038   };
00039   
00040   // Do a few final mixes of the hash to ensure the last few
00041   // bytes are well-incorporated.
00042   h ^= h >> 13;
00043   h *= m;
00044   h ^= h >> 15;
00045   
00046   return h;
00047 }


Member Data Documentation

Definition at line 13 of file hash.h.

Referenced by operator()().


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

Generated on 15 Jun 2016 for AlcapDAQ by  doxygen 1.6.1