Browse Source

hash becomes mishmash and move to codedweller namespace

master
madscientist 5 years ago
parent
commit
57459a5d9a
2 changed files with 8 additions and 8 deletions
  1. 5
    5
      mishmash.cpp
  2. 3
    3
      mishmash.hpp

+ 5
- 5
mishmash.cpp View File

inline uint32_t selectedPrime(size_t n) noexcept { return primes[mod256(n)]; } 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); uint64_t accumulator = selectedPrime(length);
for(size_t index = 0; index < length; index++) { for(size_t index = 0; index < length; index++) {
unsigned char byte = buffer[index]; unsigned char byte = buffer[index];
return accumulator & 0x00000000ffffffff; 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());
} }


} }

+ 3
- 3
mishmash.hpp View File



namespace codedweller { namespace codedweller {


uint32_t hash(const unsigned char* buffer, size_t length) noexcept;
uint32_t hash(const std::string &s) noexcept;
uint32_t hash(const std::vector<unsigned char>& v) noexcept;
uint32_t mishmash(const unsigned char* buffer, size_t length) noexcept;
uint32_t mishmash(const std::string &s) noexcept;
uint32_t mishmash(const std::vector<unsigned char>& v) noexcept;


} }

Loading…
Cancel
Save