1#include "HashFunctions.h"
2#include "HashSequence.h"
4size_t Cogs::murmur2(
const void* bytes,
const size_t length)
noexcept
6#if defined(_WIN64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(__LP64__)
7 const size_t m = 0xc6a4a7935bd1e995ull;
10 const size_t m = 0x5bd1e995;
14 const size_t seed = 0;
16 size_t h = seed ^ (length * m);
18 const size_t * data =
reinterpret_cast<const size_t *
>(bytes);
19 const size_t * end = data + (length /
sizeof(size_t));
32 const uint8_t* trailing =
reinterpret_cast<const uint8_t*
>(data);
34#if defined(_WIN64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(__LP64__)
36 case 7: h ^= size_t(trailing[6]) << 48; [[fallthrough]];
37 case 6: h ^= size_t(trailing[5]) << 40; [[fallthrough]];
38 case 5: h ^= size_t(trailing[4]) << 32; [[fallthrough]];
39 case 4: h ^= size_t(trailing[3]) << 24; [[fallthrough]];
43 case 3: h ^= size_t(trailing[2]) << 16; [[fallthrough]];
44 case 2: h ^= size_t(trailing[1]) << 8; [[fallthrough]];
45 case 1: h ^= size_t(trailing[0]);
59 size_t strSize = str.size();
60 for (
size_t i = 0; i < strSize; ++i) {
64 if ((
'A' <= chr) && (chr <=
'Z')) {
constexpr size_t hash() noexcept
Simple getter function that returns the initial value for fnv1a hashing.
COGSFOUNDATION_API size_t hashLowercase(std::string_view str, size_t hashValue=Cogs::hash()) noexcept
Get the hash code of the string converted to lowercase.
COGSFOUNDATION_API size_t murmur2(const void *bytes, const size_t length) noexcept
Implementation of the MurmurHash2 algorithm.