|
|
@@ -48,7 +48,7 @@ namespace codedweller { |
|
|
|
|
|
|
|
inline uint32_t selectedPrime(size_t n) noexcept { return primes[mod256(n)]; } |
|
|
|
|
|
|
|
uint32_t hash(const unsigned char* buffer, size_t length) noexcept { |
|
|
|
uint32_t mishmash(const unsigned char* buffer, size_t length) noexcept { |
|
|
|
uint64_t accumulator = selectedPrime(length); |
|
|
|
for(size_t index = 0; index < length; index++) { |
|
|
|
unsigned char byte = buffer[index]; |
|
|
@@ -60,12 +60,12 @@ namespace codedweller { |
|
|
|
return accumulator & 0x00000000ffffffff; |
|
|
|
} |
|
|
|
|
|
|
|
uint32_t hash(const std::string& s) noexcept { |
|
|
|
return hash((const unsigned char*) s.c_str(), s.length()); |
|
|
|
uint32_t mishmash(const std::string& s) noexcept { |
|
|
|
return mishmash((const unsigned char*) s.c_str(), s.length()); |
|
|
|
} |
|
|
|
|
|
|
|
uint32_t hash(const std::vector<unsigned char>& v) noexcept { |
|
|
|
return hash(v.data(), v.size()); |
|
|
|
uint32_t mishmash(const std::vector<unsigned char>& v) noexcept { |
|
|
|
return mishmash(v.data(), v.size()); |
|
|
|
} |
|
|
|
|
|
|
|
} |