diff options
author | babenko <babenko@yandex-team.ru> | 2022-02-10 16:49:19 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:19 +0300 |
commit | f31097c96270919a1f49360bdaaa69ea4f3fefab (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/yt/misc/hash-inl.h | |
parent | cec37806d8847aa3db53bafc9e251d4aaf325c12 (diff) | |
download | ydb-f31097c96270919a1f49360bdaaa69ea4f3fefab.tar.gz |
Restoring authorship annotation for <babenko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/yt/misc/hash-inl.h')
-rw-r--r-- | library/cpp/yt/misc/hash-inl.h | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/library/cpp/yt/misc/hash-inl.h b/library/cpp/yt/misc/hash-inl.h index 0b8873c2d32..46eeefe6204 100644 --- a/library/cpp/yt/misc/hash-inl.h +++ b/library/cpp/yt/misc/hash-inl.h @@ -1,47 +1,47 @@ -#ifndef HASH_INL_H_ -#error "Direct inclusion of this file is not allowed, include hash.h" +#ifndef HASH_INL_H_ +#error "Direct inclusion of this file is not allowed, include hash.h" // For the sake of sane code completion. #include "hash.h" -#endif - -namespace NYT { - -//////////////////////////////////////////////////////////////////////////////// - -inline void HashCombine(size_t& h, size_t k) -{ - static_assert(sizeof(size_t) == 8, "size_t must be 64 bit."); - - const size_t m = 0xc6a4a7935bd1e995ULL; - const int r = 47; - - k *= m; - k ^= k >> r; - k *= m; - - h ^= k; - h *= m; -} - -template <class T> -void HashCombine(size_t& h, const T& k) -{ - HashCombine(h, THash<T>()(k)); -} - -//////////////////////////////////////////////////////////////////////////////// - -template <class TElement, class TUnderlying> -TRandomizedHash<TElement, TUnderlying>::TRandomizedHash() - : Seed_(RandomNumber<size_t>()) -{ } - -template <class TElement, class TUnderlying> -size_t TRandomizedHash<TElement, TUnderlying>::operator ()(const TElement& element) const -{ - return Underlying_(element) + Seed_; -} - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT +#endif + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + +inline void HashCombine(size_t& h, size_t k) +{ + static_assert(sizeof(size_t) == 8, "size_t must be 64 bit."); + + const size_t m = 0xc6a4a7935bd1e995ULL; + const int r = 47; + + k *= m; + k ^= k >> r; + k *= m; + + h ^= k; + h *= m; +} + +template <class T> +void HashCombine(size_t& h, const T& k) +{ + HashCombine(h, THash<T>()(k)); +} + +//////////////////////////////////////////////////////////////////////////////// + +template <class TElement, class TUnderlying> +TRandomizedHash<TElement, TUnderlying>::TRandomizedHash() + : Seed_(RandomNumber<size_t>()) +{ } + +template <class TElement, class TUnderlying> +size_t TRandomizedHash<TElement, TUnderlying>::operator ()(const TElement& element) const +{ + return Underlying_(element) + Seed_; +} + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT |