Move libcds 1.6.0 from SVN
[libcds.git] / tests / test-hdr / set / intrusive_cuckoo_set_common.h
1 //$$CDS-header$$
2
3 namespace set {
4     namespace {
5
6         typedef IntrusiveCuckooSetHdrTest::hash_int    hash1;
7         struct hash2: private hash1
8         {
9             typedef hash1 base_class;
10
11             size_t operator()( int i ) const
12             {
13                 size_t h = ~( base_class::operator()(i));
14                 return ~h + 0x9e3779b9 + (h << 6) + (h >> 2);
15             }
16             template <typename Item>
17             size_t operator()( const Item& i ) const
18             {
19                 size_t h = ~( base_class::operator()(i));
20                 return ~h + 0x9e3779b9 + (h << 6) + (h >> 2);
21             }
22             size_t operator()( IntrusiveCuckooSetHdrTest::find_key const& i) const
23             {
24                 size_t h = ~( base_class::operator()(i));
25                 return ~h + 0x9e3779b9 + (h << 6) + (h >> 2);
26             }
27         };
28
29         template <typename T>
30         struct equal_to
31         {
32             bool operator ()(const T& v1, const T& v2 ) const
33             {
34                 return v1.key() == v2.key();
35             }
36
37             template <typename Q>
38             bool operator ()(const T& v1, const Q& v2 ) const
39             {
40                 return v1.key() == v2;
41             }
42
43             template <typename Q>
44             bool operator ()(const Q& v1, const T& v2 ) const
45             {
46                 return v1 == v2.key();
47             }
48         };
49
50     }
51 } // namespace set