Renamed MultiLevelHashSet/Map to FeldmanHashSet/Map
[libcds.git] / tests / test-hdr / set / hdr_feldman_hashset_dhp.cpp
1 //$$CDS-header$$
2
3 #include "set/hdr_feldman_hashset.h"
4 #include <cds/container/feldman_hashset_dhp.h>
5 #include "unit/print_feldman_hashset_stat.h"
6
7 namespace set {
8     namespace {
9         typedef cds::gc::DHP gc_type;
10     } // namespace
11
12     void FeldmanHashSetHdrTest::dhp_nohash()
13     {
14         typedef size_t key_type;
15
16         struct traits : public cc::feldman_hashset::traits
17         {
18             typedef get_key<key_type> hash_accessor;
19         };
20         typedef cc::FeldmanHashSet< gc_type, Item<key_type>, traits > set_type;
21         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!");
22         test_hp<set_type, nohash<key_type>>(4, 2);
23
24         typedef cc::FeldmanHashSet<
25             gc_type,
26             Item<key_type>,
27             typename cc::feldman_hashset::make_traits<
28                 cc::feldman_hashset::hash_accessor< get_key<key_type>>
29             >::type
30         > set_type2;
31         test_hp<set_type2, nohash<key_type>>(4, 2);
32     }
33
34     void FeldmanHashSetHdrTest::dhp_stdhash()
35     {
36         typedef size_t hash_type;
37
38         struct traits: public cc::feldman_hashset::traits
39         {
40             typedef get_hash<hash_type> hash_accessor;
41         };
42         typedef cc::FeldmanHashSet< gc_type, Item<hash_type>, traits > set_type;
43         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
44         test_hp<set_type, std::hash<hash_type>>(4, 2);
45
46         typedef cc::FeldmanHashSet<
47             gc_type,
48             Item<hash_type>,
49             typename cc::feldman_hashset::make_traits<
50                 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
51             >::type
52         > set_type2;
53         test_hp<set_type2, std::hash<hash_type>>(4, 2);
54     }
55
56     void FeldmanHashSetHdrTest::dhp_hash128()
57     {
58         typedef hash128 hash_type;
59
60         struct traits: public cc::feldman_hashset::traits
61         {
62             typedef get_hash<hash_type> hash_accessor;
63             typedef hash128::less less;
64         };
65         typedef cc::FeldmanHashSet< gc_type, Item<hash_type>, traits > set_type;
66         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash128!!!" );
67         test_hp<set_type, hash128::make>(4, 2);
68
69         typedef cc::FeldmanHashSet<
70             gc_type,
71             Item<hash_type>,
72             typename cc::feldman_hashset::make_traits<
73                 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
74                 , co::less< hash_type::less >
75             >::type
76         > set_type2;
77         test_hp<set_type2, hash128::make>(4, 2);
78     }
79
80     void FeldmanHashSetHdrTest::dhp_nohash_stat()
81     {
82         typedef size_t key_type;
83
84         struct traits : public cc::feldman_hashset::traits
85         {
86             typedef get_key<key_type> hash_accessor;
87             typedef cc::feldman_hashset::stat<> stat;
88         };
89         typedef cc::FeldmanHashSet< gc_type, Item<key_type>, traits > set_type;
90         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!");
91         test_hp<set_type, nohash<key_type>>(4, 2);
92
93         typedef cc::FeldmanHashSet<
94             gc_type,
95             Item<key_type>,
96             typename cc::feldman_hashset::make_traits<
97                 cc::feldman_hashset::hash_accessor< get_key<key_type>>
98                 , co::stat< cc::feldman_hashset::stat<>>
99             >::type
100         > set_type2;
101         test_hp<set_type2, nohash<key_type>>(4, 2);
102     }
103
104     void FeldmanHashSetHdrTest::dhp_stdhash_stat()
105     {
106         typedef size_t hash_type;
107
108         struct traits: public cc::feldman_hashset::traits
109         {
110             typedef get_hash<hash_type> hash_accessor;
111             typedef cc::feldman_hashset::stat<> stat;
112         };
113         typedef cc::FeldmanHashSet< gc_type, Item<hash_type>, traits > set_type;
114         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
115         test_hp<set_type, std::hash<hash_type>>(4, 2);
116
117         typedef cc::FeldmanHashSet<
118             gc_type,
119             Item<hash_type>,
120             typename cc::feldman_hashset::make_traits<
121                 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
122                 ,co::stat< cc::feldman_hashset::stat<>>
123             >::type
124         > set_type2;
125         test_hp<set_type2, std::hash<hash_type>>(4, 2);
126     }
127
128     void FeldmanHashSetHdrTest::dhp_hash128_stat()
129     {
130         typedef hash128 hash_type;
131
132         struct traits: public cc::feldman_hashset::traits
133         {
134             typedef get_hash<hash_type> hash_accessor;
135             typedef hash128::cmp  compare;
136             typedef cc::feldman_hashset::stat<> stat;
137         };
138         typedef cc::FeldmanHashSet< gc_type, Item<hash_type>, traits > set_type;
139         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
140         test_hp<set_type, hash_type::make>(4, 2);
141
142         typedef cc::FeldmanHashSet<
143             gc_type,
144             Item<hash_type>,
145             typename cc::feldman_hashset::make_traits<
146                 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
147                 ,co::stat< cc::feldman_hashset::stat<>>
148                 ,co::compare< hash128::cmp >
149             >::type
150         > set_type2;
151         test_hp<set_type2, hash_type::make>(4, 2);
152     }
153
154     void FeldmanHashSetHdrTest::dhp_nohash_5_3()
155     {
156         typedef size_t key_type;
157
158         struct traits: public cc::feldman_hashset::traits
159         {
160             typedef get_key<key_type> hash_accessor;
161         };
162         typedef cc::FeldmanHashSet< gc_type, Item<key_type>, traits > set_type;
163         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
164         test_hp<set_type, nohash<key_type>>(5, 3);
165
166         typedef cc::FeldmanHashSet<
167             gc_type,
168             Item<key_type>,
169             typename cc::feldman_hashset::make_traits<
170                 cc::feldman_hashset::hash_accessor< get_key<key_type>>
171             >::type
172         > set_type2;
173         test_hp<set_type2, nohash<key_type>>(5, 3);
174     }
175
176     void FeldmanHashSetHdrTest::dhp_stdhash_5_3()
177     {
178         typedef size_t hash_type;
179
180         struct traits: public cc::feldman_hashset::traits
181         {
182             typedef get_hash<hash_type> hash_accessor;
183         };
184         typedef cc::FeldmanHashSet< gc_type, Item<hash_type>, traits > set_type;
185         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
186         test_hp<set_type, std::hash<hash_type>>(5, 3);
187
188         typedef cc::FeldmanHashSet<
189             gc_type,
190             Item<hash_type>,
191             typename cc::feldman_hashset::make_traits<
192                 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
193             >::type
194         > set_type2;
195         test_hp<set_type2, std::hash<hash_type>>(5, 3);
196     }
197
198     void FeldmanHashSetHdrTest::dhp_hash128_4_3()
199     {
200         typedef hash128 hash_type;
201
202         struct traits: public cc::feldman_hashset::traits
203         {
204             typedef get_hash<hash_type> hash_accessor;
205             typedef co::v::sequential_consistent memory_model;
206         };
207         typedef cc::FeldmanHashSet< gc_type, Item<hash_type>, traits > set_type;
208         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
209         test_hp<set_type, hash128::make >(4, 3);
210
211         typedef cc::FeldmanHashSet<
212             gc_type,
213             Item<hash_type>,
214             typename cc::feldman_hashset::make_traits<
215                 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
216                 ,co::memory_model< co::v::sequential_consistent >
217             >::type
218         > set_type2;
219         test_hp<set_type2, hash128::make >(4, 3);
220     }
221
222     void FeldmanHashSetHdrTest::dhp_nohash_5_3_stat()
223     {
224         typedef size_t key_type;
225
226         struct traits: public cc::feldman_hashset::traits
227         {
228             typedef get_key<key_type> hash_accessor;
229             typedef cc::feldman_hashset::stat<> stat;
230         };
231         typedef cc::FeldmanHashSet< gc_type, Item<key_type>, traits > set_type;
232         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
233         test_hp<set_type, nohash<key_type>>(5, 3);
234
235         typedef cc::FeldmanHashSet<
236             gc_type,
237             Item<key_type>,
238             typename cc::feldman_hashset::make_traits<
239                 cc::feldman_hashset::hash_accessor< get_key<key_type>>
240                 ,co::stat< cc::feldman_hashset::stat<>>
241             >::type
242         > set_type2;
243         test_hp<set_type2, nohash<key_type>>(5, 3);
244     }
245
246     void FeldmanHashSetHdrTest::dhp_stdhash_5_3_stat()
247     {
248         typedef size_t hash_type;
249
250         struct traits: public cc::feldman_hashset::traits
251         {
252             typedef get_hash<hash_type> hash_accessor;
253             typedef cc::feldman_hashset::stat<> stat;
254         };
255         typedef cc::FeldmanHashSet< gc_type, Item<hash_type>, traits > set_type;
256         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
257         test_hp<set_type, std::hash<hash_type>>(5, 3);
258
259         typedef cc::FeldmanHashSet<
260             gc_type,
261             Item<hash_type>,
262             typename cc::feldman_hashset::make_traits<
263                 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
264                 ,co::stat< cc::feldman_hashset::stat<>>
265             >::type
266         > set_type2;
267         test_hp<set_type2, std::hash<hash_type>>(5, 3);
268     }
269
270     void FeldmanHashSetHdrTest::dhp_hash128_4_3_stat()
271     {
272         typedef hash128 hash_type;
273
274         struct traits: public cc::feldman_hashset::traits
275         {
276             typedef get_hash<hash_type> hash_accessor;
277             typedef cc::feldman_hashset::stat<> stat;
278             typedef hash128::less less;
279             typedef hash128::cmp compare;
280         };
281         typedef cc::FeldmanHashSet< gc_type, Item<hash_type>, traits > set_type;
282         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
283         test_hp<set_type, hash_type::make>(4, 3);
284
285         typedef cc::FeldmanHashSet<
286             gc_type,
287             Item<hash_type>,
288             typename cc::feldman_hashset::make_traits<
289                 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
290                 , co::stat< cc::feldman_hashset::stat<>>
291                 , co::less< hash_type::less >
292                 , co::compare< hash128::cmp >
293             >::type
294         > set_type2;
295         test_hp<set_type2, hash_type::make>(4, 3);
296     }
297
298
299 } // namespace set