From 230e61091b401b8b2bb9496d557a15660fb5072b Mon Sep 17 00:00:00 2001 From: Aleksi Lindeman <0xdec05eba@gmail.com> Date: Fri, 9 Mar 2018 10:26:55 +0100 Subject: Partially implement 'add' operation --- include/Hash.hpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'include/Hash.hpp') diff --git a/include/Hash.hpp b/include/Hash.hpp index d7c90b0..bd87b69 100644 --- a/include/Hash.hpp +++ b/include/Hash.hpp @@ -1,7 +1,6 @@ #pragma once #include "utils.hpp" -#include #include #include @@ -9,6 +8,15 @@ 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: @@ -21,6 +29,7 @@ namespace odhtdb 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; } -- cgit v1.2.3