3 #ifndef CDSUNIT_SET_TYPE_STRIPED_H
4 #define CDSUNIT_SET_TYPE_STRIPED_H
6 #include "set2/set_type.h"
8 #include <cds/container/striped_set/std_list.h>
9 #include <cds/container/striped_set/std_vector.h>
10 #include <cds/container/striped_set/std_set.h>
11 #include <cds/container/striped_set/std_hash_set.h>
12 #include <cds/container/striped_set/boost_unordered_set.h>
14 #include <boost/version.hpp>
15 #if BOOST_VERSION >= 104800
16 # include <cds/container/striped_set/boost_slist.h>
17 # include <cds/container/striped_set/boost_list.h>
18 # include <cds/container/striped_set/boost_vector.h>
19 # include <cds/container/striped_set/boost_stable_vector.h>
20 # include <cds/container/striped_set/boost_set.h>
21 # include <cds/container/striped_set/boost_flat_set.h>
23 #include <cds/container/striped_set.h>
27 template <typename Key, typename Val>
28 struct set_type< cc::striped_set::implementation_tag, Key, Val >: public set_type_base< Key, Val >
30 typedef set_type_base< Key, Val > base_class;
31 using base_class::key_val;
32 using base_class::compare;
33 using base_class::less;
34 using base_class::hash;
37 // ***************************************************************************
40 // for sequential containers
41 template <class BucketEntry, typename... Options>
42 class StripedHashSet_seq:
43 public cc::StripedSet< BucketEntry,
44 co::mutex_policy< cc::striped_set::striping<> >
45 ,co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
49 typedef cc::StripedSet< BucketEntry,
50 co::mutex_policy< cc::striped_set::striping<> >
51 ,co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
54 typedef typename base_class::resizing_policy resizing_policy_t;
56 resizing_policy_t m_placeHolder;
58 StripedHashSet_seq( size_t nCapacity, size_t nLoadFactor )
59 : base_class( nCapacity / nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( nLoadFactor )) )
62 template <typename Q, typename Less>
63 bool erase_with( Q const& v, Less /*pred*/ )
65 return base_class::erase( v );
69 // for non-sequential ordered containers
70 template <class BucketEntry, typename... Options>
71 class StripedHashSet_ord:
72 public cc::StripedSet< BucketEntry,
73 co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
74 ,co::mutex_policy< cc::striped_set::striping<> >
78 typedef cc::StripedSet< BucketEntry,
79 co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
80 ,co::mutex_policy< cc::striped_set::striping<> >
83 typedef typename base_class::resizing_policy resizing_policy_t;
85 resizing_policy_t m_placeHolder;
87 StripedHashSet_ord( size_t /*nCapacity*/, size_t nLoadFactor )
88 : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( nLoadFactor * 1024 )) )
91 template <typename Q, typename Less>
92 bool erase_with( Q const& v, Less /*pred*/ )
94 return base_class::erase( v );
98 typedef StripedHashSet_seq<
104 typedef StripedHashSet_seq<
105 std::vector< key_val >
110 #if BOOST_VERSION >= 104800
111 typedef StripedHashSet_seq<
112 boost::container::slist< key_val >
115 > StripedSet_boost_slist;
117 typedef StripedHashSet_seq<
118 boost::container::list< key_val >
121 > StripedSet_boost_list;
123 typedef StripedHashSet_seq<
124 boost::container::vector< key_val >
127 > StripedSet_boost_vector;
129 typedef StripedHashSet_seq<
130 boost::container::stable_vector< key_val >
133 > StripedSet_boost_stable_vector;
136 typedef StripedHashSet_ord<
137 std::set< key_val, less >
141 typedef StripedHashSet_ord<
142 std::unordered_set< key_val, hash, equal_to >
144 > StripedSet_hashset;
146 #if BOOST_VERSION >= 104800
147 typedef StripedHashSet_ord<
148 boost::container::set< key_val, less >
150 > StripedSet_boost_set;
152 typedef StripedHashSet_ord<
153 boost::container::flat_set< key_val, less >
155 > StripedSet_boost_flat_set;
158 typedef StripedHashSet_ord<
159 boost::unordered_set< key_val, hash, equal_to >
161 > StripedSet_boost_unordered_set;
164 // ***************************************************************************
167 // for sequential containers
168 template <class BucketEntry, typename... Options>
169 class RefinableHashSet_seq:
170 public cc::StripedSet< BucketEntry,
171 co::mutex_policy< cc::striped_set::refinable<> >
172 ,co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
176 typedef cc::StripedSet< BucketEntry,
177 co::mutex_policy< cc::striped_set::refinable<> >
178 ,co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
181 typedef typename base_class::resizing_policy resizing_policy_t;
183 resizing_policy_t m_placeHolder;
185 RefinableHashSet_seq( size_t nCapacity, size_t nLoadFactor )
186 : base_class( nCapacity / nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( nLoadFactor )) )
189 template <typename Q, typename Less>
190 bool erase_with( Q const& v, Less /*pred*/ )
192 return base_class::erase( v );
196 // for non-sequential ordered containers
197 template <class BucketEntry, typename... Options>
198 class RefinableHashSet_ord:
199 public cc::StripedSet< BucketEntry,
200 co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
201 ,co::mutex_policy< cc::striped_set::refinable<> >
205 typedef cc::StripedSet< BucketEntry,
206 co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
207 ,co::mutex_policy< cc::striped_set::refinable<> >
210 typedef typename base_class::resizing_policy resizing_policy_t;
212 resizing_policy_t m_placeHolder;
214 RefinableHashSet_ord( size_t /*nCapacity*/, size_t nLoadFactor )
215 : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( nLoadFactor * 1024 )) )
218 template <typename Q, typename Less>
219 bool erase_with( Q const& v, Less /*pred*/ )
221 return base_class::erase( v );
225 typedef RefinableHashSet_seq<
231 typedef RefinableHashSet_seq<
232 std::vector< key_val >
235 > RefinableSet_vector;
237 #if BOOST_VERSION >= 104800
238 typedef RefinableHashSet_seq<
239 boost::container::slist< key_val >
242 > RefinableSet_boost_slist;
244 typedef RefinableHashSet_seq<
245 boost::container::list< key_val >
248 > RefinableSet_boost_list;
250 typedef RefinableHashSet_seq<
251 boost::container::vector< key_val >
254 > RefinableSet_boost_vector;
256 typedef RefinableHashSet_seq<
257 boost::container::stable_vector< key_val >
260 > RefinableSet_boost_stable_vector;
263 typedef RefinableHashSet_ord<
264 std::set< key_val, less >
268 typedef RefinableHashSet_ord<
269 std::unordered_set< key_val, hash, equal_to >
271 > RefinableSet_hashset;
273 #if BOOST_VERSION >= 104800
274 typedef RefinableHashSet_ord<
275 boost::container::set< key_val, less >
277 > RefinableSet_boost_set;
279 typedef RefinableHashSet_ord<
280 boost::container::flat_set< key_val, less >
282 > RefinableSet_boost_flat_set;
285 typedef RefinableHashSet_ord<
286 boost::unordered_set< key_val, hash, equal_to >
288 > RefinableSet_boost_unordered_set;
293 #endif // #ifndef CDSUNIT_SET_TYPE_STRIPED_H