diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-03-13 06:26:06 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-08-18 23:25:46 +0200 |
commit | 5a8727e34b938b70623ca865273fd81c7604b461 (patch) | |
tree | a2921e90aa454072dc58fced36b508f67f5d1226 /include/Hash.hpp | |
parent | 9ffc25c9d99fe86d4789108d1d8615ecb0388cc6 (diff) |
Expose include dir
Diffstat (limited to 'include/Hash.hpp')
-rw-r--r-- | include/Hash.hpp | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/include/Hash.hpp b/include/Hash.hpp deleted file mode 100644 index 9dce168..0000000 --- a/include/Hash.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once - -#include "utils.hpp" -#include <stdexcept> -#include <unordered_map> -#include <unordered_set> - -namespace odhtdb -{ - const int HASH_BYTE_SIZE = 32; - - // Source: https://stackoverflow.com/a/11414104 (public license) - static size_t fnvHash(const unsigned char *key, int len) - { - size_t h = 2166136261; - for (int i = 0; i < len; i++) - h = (h * 16777619) ^ key[i]; - return h; - } - - class HashException : public std::runtime_error - { - public: - HashException(const std::string &errMsg) : std::runtime_error(errMsg) {} - }; - - class Hash - { - public: - Hash(); - // Throws HashException on failure - Hash(const void *input, const size_t inputSize); - Hash(const Hash &other); - - void* getData() const { return (void*)data; } - size_t getSize() const { return HASH_BYTE_SIZE; } - - size_t operator()() const; - bool operator==(const Hash &other) const; - - std::string toString() const; - private: - char data[HASH_BYTE_SIZE]; - }; - - struct HashHasher - { - size_t operator()(const Hash &hash) const - { - return hash(); - } - }; - - template <typename ValueType> - using MapHash = std::unordered_map<Hash, ValueType, HashHasher>; - - using SetHash = std::unordered_set<Hash, HashHasher>; -} |