2 This file is a part of libcds - Concurrent Data Structures library
4 (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
6 Source code repo: http://github.com/khizmax/libcds/
7 Download: http://sourceforge.net/projects/libcds/files/
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are met:
12 * Redistributions of source code must retain the above copyright notice, this
13 list of conditions and the following disclaimer.
15 * Redistributions in binary form must reproduce the above copyright notice,
16 this list of conditions and the following disclaimer in the documentation
17 and/or other materials provided with the distribution.
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "set/hdr_intrusive_feldman_hashset.h"
32 #include <cds/intrusive/feldman_hashset_dhp.h>
33 #include "unit/print_feldman_hashset_stat.h"
37 typedef cds::gc::DHP gc_type;
40 void IntrusiveFeldmanHashSetHdrTest::dhp_nohash()
42 typedef size_t key_type;
44 struct traits : public ci::feldman_hashset::traits
46 typedef get_key<key_type> hash_accessor;
47 typedef item_disposer disposer;
49 typedef ci::FeldmanHashSet< gc_type, Item<key_type>, traits > set_type;
50 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!");
51 test_hp<set_type, nohash<key_type>>(4, 2);
53 typedef ci::FeldmanHashSet<
56 typename ci::feldman_hashset::make_traits<
57 ci::feldman_hashset::hash_accessor< get_key<key_type>>
58 , ci::opt::disposer< item_disposer >
61 test_hp<set_type2, nohash<key_type>>(4, 2);
64 void IntrusiveFeldmanHashSetHdrTest::dhp_stdhash()
66 typedef size_t hash_type;
68 struct traits: public ci::feldman_hashset::traits
70 typedef get_hash<hash_type> hash_accessor;
71 typedef item_disposer disposer;
73 typedef ci::FeldmanHashSet< gc_type, Item<hash_type>, traits > set_type;
74 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
75 test_hp<set_type, std::hash<hash_type>>(4, 2);
77 typedef ci::FeldmanHashSet<
80 typename ci::feldman_hashset::make_traits<
81 ci::feldman_hashset::hash_accessor< get_hash<hash_type>>
82 , ci::opt::disposer< item_disposer >
85 test_hp<set_type2, std::hash<hash_type>>(4, 2);
88 void IntrusiveFeldmanHashSetHdrTest::dhp_hash128()
90 typedef hash128 hash_type;
92 struct traits: public ci::feldman_hashset::traits
94 typedef get_hash<hash_type> hash_accessor;
95 typedef item_disposer disposer;
96 typedef hash128::less less;
98 typedef ci::FeldmanHashSet< gc_type, Item<hash_type>, traits > set_type;
99 static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash128!!!" );
100 test_hp<set_type, hash128::make>(4, 2);
102 typedef ci::FeldmanHashSet<
105 typename ci::feldman_hashset::make_traits<
106 ci::feldman_hashset::hash_accessor< get_hash<hash_type>>
107 , ci::opt::disposer< item_disposer >
108 , ci::opt::less< hash_type::less >
111 test_hp<set_type2, hash128::make>(4, 2);
114 void IntrusiveFeldmanHashSetHdrTest::dhp_nohash_stat()
116 typedef size_t key_type;
118 struct traits : public ci::feldman_hashset::traits
120 typedef get_key<key_type> hash_accessor;
121 typedef item_disposer disposer;
122 typedef ci::feldman_hashset::stat<> stat;
124 typedef ci::FeldmanHashSet< gc_type, Item<key_type>, traits > set_type;
125 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!");
126 test_hp<set_type, nohash<key_type>>(4, 2);
128 typedef ci::FeldmanHashSet<
131 typename ci::feldman_hashset::make_traits<
132 ci::feldman_hashset::hash_accessor< get_key<key_type>>
133 , ci::opt::disposer< item_disposer >
134 , co::stat< ci::feldman_hashset::stat<>>
137 test_hp<set_type2, nohash<key_type>>(4, 2);
140 void IntrusiveFeldmanHashSetHdrTest::dhp_stdhash_stat()
142 typedef size_t hash_type;
144 struct traits: public ci::feldman_hashset::traits
146 typedef get_hash<hash_type> hash_accessor;
147 typedef item_disposer disposer;
148 typedef ci::feldman_hashset::stat<> stat;
150 typedef ci::FeldmanHashSet< gc_type, Item<hash_type>, traits > set_type;
151 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
152 test_hp<set_type, std::hash<hash_type>>(4, 2);
154 typedef ci::FeldmanHashSet<
157 typename ci::feldman_hashset::make_traits<
158 ci::feldman_hashset::hash_accessor< get_hash<hash_type>>
159 , ci::opt::disposer< item_disposer >
160 ,co::stat< ci::feldman_hashset::stat<>>
163 test_hp<set_type2, std::hash<hash_type>>(4, 2);
166 void IntrusiveFeldmanHashSetHdrTest::dhp_hash128_stat()
168 typedef hash128 hash_type;
170 struct traits: public ci::feldman_hashset::traits
172 typedef get_hash<hash_type> hash_accessor;
173 typedef item_disposer disposer;
174 typedef hash128::cmp compare;
175 typedef ci::feldman_hashset::stat<> stat;
177 typedef ci::FeldmanHashSet< gc_type, Item<hash_type>, traits > set_type;
178 static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
179 test_hp<set_type, hash_type::make>(4, 2);
181 typedef ci::FeldmanHashSet<
184 typename ci::feldman_hashset::make_traits<
185 ci::feldman_hashset::hash_accessor< get_hash<hash_type>>
186 , ci::opt::disposer< item_disposer >
187 ,co::stat< ci::feldman_hashset::stat<>>
188 ,co::compare< hash128::cmp >
191 test_hp<set_type2, hash_type::make>(4, 2);
194 void IntrusiveFeldmanHashSetHdrTest::dhp_nohash_5_3()
196 typedef size_t key_type;
198 struct traits : public ci::feldman_hashset::traits
200 typedef get_key<key_type> hash_accessor;
201 typedef item_disposer disposer;
203 typedef ci::FeldmanHashSet< gc_type, Item<key_type>, traits > set_type;
204 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!");
205 test_hp<set_type, nohash<key_type>>(5, 3);
207 typedef ci::FeldmanHashSet<
210 typename ci::feldman_hashset::make_traits<
211 ci::feldman_hashset::hash_accessor< get_key<key_type>>
212 , ci::opt::disposer< item_disposer >
215 test_hp<set_type2, nohash<key_type>>(5, 3);
218 void IntrusiveFeldmanHashSetHdrTest::dhp_stdhash_5_3()
220 typedef size_t hash_type;
222 struct traits: public ci::feldman_hashset::traits
224 typedef get_hash<hash_type> hash_accessor;
225 typedef item_disposer disposer;
227 typedef ci::FeldmanHashSet< gc_type, Item<hash_type>, traits > set_type;
228 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
229 test_hp<set_type, std::hash<hash_type>>(5, 3);
231 typedef ci::FeldmanHashSet<
234 typename ci::feldman_hashset::make_traits<
235 ci::feldman_hashset::hash_accessor< get_hash<hash_type>>
236 , ci::opt::disposer< item_disposer >
239 test_hp<set_type2, std::hash<hash_type>>(5, 3);
242 void IntrusiveFeldmanHashSetHdrTest::dhp_hash128_4_3()
244 typedef hash128 hash_type;
246 struct traits: public ci::feldman_hashset::traits
248 typedef get_hash<hash_type> hash_accessor;
249 typedef item_disposer disposer;
250 typedef co::v::sequential_consistent memory_model;
252 typedef ci::FeldmanHashSet< gc_type, Item<hash_type>, traits > set_type;
253 static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
254 test_hp<set_type, hash128::make >(4, 3);
256 typedef ci::FeldmanHashSet<
259 typename ci::feldman_hashset::make_traits<
260 ci::feldman_hashset::hash_accessor< get_hash<hash_type>>
261 , ci::opt::disposer< item_disposer >
262 ,co::memory_model< co::v::sequential_consistent >
265 test_hp<set_type2, hash128::make >(4, 3);
268 void IntrusiveFeldmanHashSetHdrTest::dhp_nohash_5_3_stat()
270 typedef size_t key_type;
272 struct traits: public ci::feldman_hashset::traits
274 typedef get_key<key_type> hash_accessor;
275 typedef item_disposer disposer;
276 typedef ci::feldman_hashset::stat<> stat;
278 typedef ci::FeldmanHashSet< gc_type, Item<key_type>, traits > set_type;
279 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
280 test_hp<set_type, nohash<key_type>>(5, 3);
282 typedef ci::FeldmanHashSet<
285 typename ci::feldman_hashset::make_traits<
286 ci::feldman_hashset::hash_accessor< get_key<key_type>>
287 , ci::opt::disposer< item_disposer >
288 ,co::stat< ci::feldman_hashset::stat<>>
291 test_hp<set_type2, nohash<key_type>>(5, 3);
294 void IntrusiveFeldmanHashSetHdrTest::dhp_stdhash_5_3_stat()
296 typedef size_t hash_type;
298 struct traits: public ci::feldman_hashset::traits
300 typedef get_hash<hash_type> hash_accessor;
301 typedef item_disposer disposer;
302 typedef ci::feldman_hashset::stat<> stat;
304 typedef ci::FeldmanHashSet< gc_type, Item<hash_type>, traits > set_type;
305 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
306 test_hp<set_type, std::hash<hash_type>>(5, 3);
308 typedef ci::FeldmanHashSet<
311 typename ci::feldman_hashset::make_traits<
312 ci::feldman_hashset::hash_accessor< get_hash<hash_type>>
313 , ci::opt::disposer< item_disposer >
314 ,co::stat< ci::feldman_hashset::stat<>>
317 test_hp<set_type2, std::hash<hash_type>>(5, 3);
320 void IntrusiveFeldmanHashSetHdrTest::dhp_hash128_4_3_stat()
322 typedef hash128 hash_type;
324 struct traits: public ci::feldman_hashset::traits
326 typedef get_hash<hash_type> hash_accessor;
327 typedef item_disposer disposer;
328 typedef ci::feldman_hashset::stat<> stat;
329 typedef hash128::less less;
330 typedef hash128::cmp compare;
332 typedef ci::FeldmanHashSet< gc_type, Item<hash_type>, traits > set_type;
333 static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
334 test_hp<set_type, hash_type::make>(4, 3);
336 typedef ci::FeldmanHashSet<
339 typename ci::feldman_hashset::make_traits<
340 ci::feldman_hashset::hash_accessor< get_hash<hash_type>>
341 , ci::opt::disposer< item_disposer >
342 , co::stat< ci::feldman_hashset::stat<>>
343 , co::less< hash_type::less >
344 , co::compare< hash128::cmp >
347 test_hp<set_type2, hash_type::make>(4, 3);