e78f35a22709a258a166ff6c44295a5182ef4489
[libcds.git] / tests / test-hdr / set / hdr_intrusive_multilevel_hashset_dhp.cpp
1 //$$CDS-header$$
2
3 #include "set/hdr_intrusive_multilevel_hashset.h"
4 #include <cds/intrusive/multilevel_hashset_dhp.h>
5 #include "unit/print_multilevel_hashset_stat.h"
6
7 namespace set {
8     namespace {
9         typedef cds::gc::DHP gc_type;
10     } // namespace
11
12     void IntrusiveMultiLevelHashSetHdrTest::dhp_stdhash()
13     {
14         typedef size_t hash_type;
15
16         struct traits: public ci::multilevel_hashset::traits
17         {
18             typedef get_hash<hash_type> hash_accessor;
19             typedef item_disposer disposer;
20         };
21         typedef ci::MultiLevelHashSet< gc_type, Item<hash_type>, traits > set_type;
22         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
23         test_hp<set_type, std::hash<hash_type>>(4, 2);
24
25         typedef ci::MultiLevelHashSet<
26             gc_type,
27             Item<hash_type>,
28             typename ci::multilevel_hashset::make_traits<
29                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
30                 , ci::opt::disposer< item_disposer >
31             >::type
32         > set_type2;
33         test_hp<set_type2, std::hash<hash_type>>(4, 2);
34     }
35
36     void IntrusiveMultiLevelHashSetHdrTest::dhp_hash128()
37     {
38         typedef hash128 hash_type;
39
40         struct traits: public ci::multilevel_hashset::traits
41         {
42             typedef get_hash<hash_type> hash_accessor;
43             typedef item_disposer disposer;
44             typedef hash128::less less;
45         };
46         typedef ci::MultiLevelHashSet< gc_type, Item<hash_type>, traits > set_type;
47         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash128!!!" );
48         test_hp<set_type, hash128::make>(4, 2);
49
50         typedef ci::MultiLevelHashSet<
51             gc_type,
52             Item<hash_type>,
53             typename ci::multilevel_hashset::make_traits<
54                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
55                 , ci::opt::disposer< item_disposer >
56                 , ci::opt::less< hash_type::less >
57             >::type
58         > set_type2;
59         test_hp<set_type2, hash128::make>(4, 2);
60     }
61
62     void IntrusiveMultiLevelHashSetHdrTest::dhp_stdhash_stat()
63     {
64         typedef size_t hash_type;
65
66         struct traits: public ci::multilevel_hashset::traits
67         {
68             typedef get_hash<hash_type> hash_accessor;
69             typedef item_disposer disposer;
70             typedef ci::multilevel_hashset::stat<> stat;
71         };
72         typedef ci::MultiLevelHashSet< gc_type, Item<hash_type>, traits > set_type;
73         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
74         test_hp<set_type, std::hash<hash_type>>(4, 2);
75
76         typedef ci::MultiLevelHashSet<
77             gc_type,
78             Item<hash_type>,
79             typename ci::multilevel_hashset::make_traits<
80                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
81                 , ci::opt::disposer< item_disposer >
82                 ,co::stat< ci::multilevel_hashset::stat<>>
83             >::type
84         > set_type2;
85         test_hp<set_type2, std::hash<hash_type>>(4, 2);
86     }
87
88     void IntrusiveMultiLevelHashSetHdrTest::dhp_hash128_stat()
89     {
90         typedef hash128 hash_type;
91
92         struct traits: public ci::multilevel_hashset::traits
93         {
94             typedef get_hash<hash_type> hash_accessor;
95             typedef item_disposer disposer;
96             typedef hash128::cmp  compare;
97             typedef ci::multilevel_hashset::stat<> stat;
98         };
99         typedef ci::MultiLevelHashSet< gc_type, Item<hash_type>, traits > set_type;
100         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
101         test_hp<set_type, hash_type::make>(4, 2);
102
103         typedef ci::MultiLevelHashSet<
104             gc_type,
105             Item<hash_type>,
106             typename ci::multilevel_hashset::make_traits<
107                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
108                 , ci::opt::disposer< item_disposer >
109                 ,co::stat< ci::multilevel_hashset::stat<>>
110                 ,co::compare< hash128::cmp >
111             >::type
112         > set_type2;
113         test_hp<set_type2, hash_type::make>(4, 2);
114     }
115
116     void IntrusiveMultiLevelHashSetHdrTest::dhp_stdhash_5_3()
117     {
118         typedef size_t hash_type;
119
120         struct traits: public ci::multilevel_hashset::traits
121         {
122             typedef get_hash<hash_type> hash_accessor;
123             typedef item_disposer disposer;
124         };
125         typedef ci::MultiLevelHashSet< gc_type, Item<hash_type>, traits > set_type;
126         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
127         test_hp<set_type, std::hash<hash_type>>(5, 3);
128
129         typedef ci::MultiLevelHashSet<
130             gc_type,
131             Item<hash_type>,
132             typename ci::multilevel_hashset::make_traits<
133                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
134                 , ci::opt::disposer< item_disposer >
135             >::type
136         > set_type2;
137         test_hp<set_type2, std::hash<hash_type>>(5, 3);
138     }
139
140     void IntrusiveMultiLevelHashSetHdrTest::dhp_hash128_4_3()
141     {
142         typedef hash128 hash_type;
143
144         struct traits: public ci::multilevel_hashset::traits
145         {
146             typedef get_hash<hash_type> hash_accessor;
147             typedef item_disposer disposer;
148             typedef co::v::sequential_consistent memory_model;
149         };
150         typedef ci::MultiLevelHashSet< gc_type, Item<hash_type>, traits > set_type;
151         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
152         test_hp<set_type, hash128::make >(4, 3);
153
154         typedef ci::MultiLevelHashSet<
155             gc_type,
156             Item<hash_type>,
157             typename ci::multilevel_hashset::make_traits<
158                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
159                 , ci::opt::disposer< item_disposer >
160                 ,co::memory_model< co::v::sequential_consistent >
161             >::type
162         > set_type2;
163         test_hp<set_type2, hash128::make >(4, 3);
164     }
165
166     void IntrusiveMultiLevelHashSetHdrTest::dhp_stdhash_5_3_stat()
167     {
168         typedef size_t hash_type;
169
170         struct traits: public ci::multilevel_hashset::traits
171         {
172             typedef get_hash<hash_type> hash_accessor;
173             typedef item_disposer disposer;
174             typedef ci::multilevel_hashset::stat<> stat;
175         };
176         typedef ci::MultiLevelHashSet< gc_type, Item<hash_type>, traits > set_type;
177         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
178         test_hp<set_type, std::hash<hash_type>>(5, 3);
179
180         typedef ci::MultiLevelHashSet<
181             gc_type,
182             Item<hash_type>,
183             typename ci::multilevel_hashset::make_traits<
184                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
185                 , ci::opt::disposer< item_disposer >
186                 ,co::stat< ci::multilevel_hashset::stat<>>
187             >::type
188         > set_type2;
189         test_hp<set_type2, std::hash<hash_type>>(5, 3);
190     }
191
192     void IntrusiveMultiLevelHashSetHdrTest::dhp_hash128_4_3_stat()
193     {
194         typedef hash128 hash_type;
195
196         struct traits: public ci::multilevel_hashset::traits
197         {
198             typedef get_hash<hash_type> hash_accessor;
199             typedef item_disposer disposer;
200             typedef ci::multilevel_hashset::stat<> stat;
201             typedef hash128::less less;
202             typedef hash128::cmp compare;
203         };
204         typedef ci::MultiLevelHashSet< gc_type, Item<hash_type>, traits > set_type;
205         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
206         test_hp<set_type, hash_type::make>(4, 3);
207
208         typedef ci::MultiLevelHashSet<
209             gc_type,
210             Item<hash_type>,
211             typename ci::multilevel_hashset::make_traits<
212                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
213                 , ci::opt::disposer< item_disposer >
214                 , co::stat< ci::multilevel_hashset::stat<>>
215                 , co::less< hash_type::less >
216                 , co::compare< hash128::cmp >
217             >::type
218         > set_type2;
219         test_hp<set_type2, hash_type::make>(4, 3);
220     }
221
222 } // namespace set