26 #include <ndn-cxx/util/backports.hpp> 33 return (x << r) | (x >> (32 - r));
37 murmurHash3(uint32_t nHashSeed,
const std::vector<unsigned char>& vDataToHash)
39 uint32_t h1 = nHashSeed;
40 const uint32_t c1 = 0xcc9e2d51;
41 const uint32_t c2 = 0x1b873593;
43 const size_t nblocks = vDataToHash.size() / 4;
47 const uint32_t * blocks = (
const uint32_t *)(&vDataToHash[0] + nblocks*4);
49 for (
size_t i = -nblocks; i; i++) {
50 uint32_t k1 = blocks[i];
63 const uint8_t * tail = (
const uint8_t*)(&vDataToHash[0] + nblocks*4);
67 switch (vDataToHash.size() & 3) {
78 k1 *= c1; k1 =
ROTL32(k1,15); k1 *= c2; h1 ^= k1;
83 h1 ^= vDataToHash.size();
96 return murmurHash3(nHashSeed, std::vector<unsigned char>(str.begin(), str.end()));
103 std::vector<unsigned char>((
unsigned char*)&value,
104 (
unsigned char*)&value +
sizeof(uint32_t)));
uint32_t murmurHash3(uint32_t nHashSeed, const std::vector< unsigned char > &vDataToHash)
static uint32_t ROTL32(uint32_t x, int8_t r)