aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/misc/hash.h
blob: d44ddc9cad87e0913915307a62dd505c344bf35b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once

#include <util/generic/hash.h>

#include <util/random/random.h> 
 
namespace NYT {

////////////////////////////////////////////////////////////////////////////////

//! Updates #h with #k.
//! Cf. |boost::hash_combine|.
void HashCombine(size_t& h, size_t k);

//! Updates #h with the hash of #k.
//! Cf. |boost::hash_combine|.
template <class T>
void HashCombine(size_t& h, const T& k);

////////////////////////////////////////////////////////////////////////////////
 
//! Provides a hasher that randomizes the results of another one. 
template <class TElement, class TUnderlying = ::THash<TElement>> 
class TRandomizedHash 
{ 
public: 
    TRandomizedHash();
    size_t operator () (const TElement& element) const;
 
private: 
    size_t Seed_; 
    TUnderlying Underlying_; 
 
}; 
 
////////////////////////////////////////////////////////////////////////////////

} // namespace NYT 
 
#define HASH_INL_H_
#include "hash-inl.h"
#undef HASH_INL_H_