/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Copyright 2016-2018 Danny Robson */ #ifndef CRUFT_UTIL_HASH_XXHASH_HPP #define CRUFT_UTIL_HASH_XXHASH_HPP #include "../view.hpp" #include #include namespace cruft::hash { template class xxhash { public: static_assert (std::is_same::value || std::is_same::value); using digest_t = WordT; using word_t = WordT; static constexpr int block_bytes = 4 * sizeof (word_t); static constexpr word_t DEFAULT_SEED = 0; xxhash (word_t seed = DEFAULT_SEED); digest_t operator() (const cruft::view data); private: word_t m_seed; }; using xxhash32 = xxhash; using xxhash64 = xxhash; } #endif