3 #ifndef CDSUNIT_MAP_TYPE_MICHAEL_H
4 #define CDSUNIT_MAP_TYPE_MICHAEL_H
6 #include "map2/map_type.h"
7 #include <cds/container/striped_map/std_list.h>
8 #include <cds/container/striped_map/std_map.h>
9 #include <cds/container/striped_map/std_hash_map.h>
11 #include <boost/version.hpp>
12 #if BOOST_VERSION >= 104800
13 # include <cds/container/striped_map/boost_list.h>
14 # include <cds/container/striped_map/boost_slist.h>
15 # include <cds/container/striped_map/boost_map.h>
16 # include <cds/container/striped_map/boost_flat_map.h>
18 #include <cds/container/striped_map/boost_unordered_map.h>
19 #include <cds/container/striped_map.h>
23 template <typename Key, typename Value>
24 struct map_type< cc::striped_set::implementation_tag, Key, Value >: public map_type_base< Key, Value >
26 typedef map_type_base< Key, Value > base_class;
27 typedef typename base_class::compare compare;
28 typedef typename base_class::less less;
29 typedef typename base_class::equal_to equal_to;
30 typedef typename base_class::key_hash key_hash;
31 typedef typename base_class::hash hash;
32 typedef typename base_class::hash2 hash2;
34 // for sequential containers
35 template <class BucketEntry, typename... Options>
36 class StripedHashMap_seq:
37 public cc::StripedMap< BucketEntry,
38 co::mutex_policy< cc::striped_set::striping<> >
39 ,co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
43 typedef cc::StripedMap< BucketEntry,
44 co::mutex_policy< cc::striped_set::striping<> >
45 ,co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
48 typedef typename base_class::resizing_policy resizing_policy_t;
50 resizing_policy_t m_placeHolder;
52 StripedHashMap_seq( size_t nCapacity, size_t nLoadFactor )
53 : base_class( nCapacity / nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( nLoadFactor )) )
57 // for non-sequential ordered containers
58 template <class BucketEntry, typename... Options>
59 class StripedHashMap_ord:
60 public cc::StripedMap< BucketEntry,
61 co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
62 ,co::mutex_policy< cc::striped_set::striping<> >
66 typedef cc::StripedMap< BucketEntry,
67 co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
68 ,co::mutex_policy< cc::striped_set::striping<> >
71 typedef typename base_class::resizing_policy resizing_policy_t;
73 resizing_policy_t m_placeHolder;
75 StripedHashMap_ord( size_t /*nCapacity*/, size_t nLoadFactor )
76 : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( nLoadFactor * 1024 )) )
81 typedef StripedHashMap_seq<
82 std::list< std::pair< Key const, Value > >
87 # if (CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600
88 typedef StripedHashMap_ord<
89 stdext::hash_map< Key, Value, stdext::hash_compare<Key, less > >
93 typedef StripedHashMap_ord<
94 std::unordered_map< Key, Value, hash, equal_to >
99 typedef StripedHashMap_ord<
100 std::map< Key, Value, less >
104 typedef StripedHashMap_ord<
105 boost::unordered_map< Key, Value, hash, equal_to >
107 > StripedMap_boost_unordered_map;
109 # if BOOST_VERSION >= 104800
110 typedef StripedHashMap_seq<
111 boost::container::slist< std::pair< Key const, Value > >
116 typedef StripedHashMap_seq<
117 boost::container::list< std::pair< Key const, Value > >
120 > StripedMap_boost_list;
122 typedef StripedHashMap_ord<
123 boost::container::map< Key, Value, less >
125 > StripedMap_boost_map;
127 typedef StripedHashMap_ord<
128 boost::container::flat_map< Key, Value, less >
130 > StripedMap_boost_flat_map;
131 # endif // BOOST_VERSION >= 104800
134 // ***************************************************************************
137 // for sequential containers
138 template <class BucketEntry, typename... Options>
139 class RefinableHashMap_seq:
140 public cc::StripedMap< BucketEntry,
141 co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
142 ,co::mutex_policy< cc::striped_set::refinable<> >
146 typedef cc::StripedMap< BucketEntry,
147 co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
148 ,co::mutex_policy< cc::striped_set::refinable<> >
151 typedef typename base_class::resizing_policy resizing_policy_t;
153 resizing_policy_t m_placeHolder;
155 RefinableHashMap_seq( size_t nCapacity, size_t nLoadFactor )
156 : base_class( nCapacity / nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( nLoadFactor )) )
160 // for non-sequential ordered containers
161 template <class BucketEntry, typename... Options>
162 class RefinableHashMap_ord:
163 public cc::StripedMap< BucketEntry,
164 co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
165 ,co::mutex_policy< cc::striped_set::refinable<> >
169 typedef cc::StripedMap< BucketEntry,
170 co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
171 ,co::mutex_policy< cc::striped_set::refinable<> >
174 typedef typename base_class::resizing_policy resizing_policy_t;
176 resizing_policy_t m_placeHolder;
178 RefinableHashMap_ord( size_t /*nCapacity*/, size_t nLoadFactor )
179 : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( nLoadFactor * 1024 )) )
184 typedef RefinableHashMap_seq<
185 std::list< std::pair< Key const, Value > >
190 # if BOOST_VERSION >= 104800
191 typedef RefinableHashMap_seq<
192 boost::container::slist< std::pair< Key const, Value > >
195 > RefinableMap_slist;
198 typedef RefinableHashMap_ord<
199 std::map< Key, Value, less >
203 typedef RefinableHashMap_ord<
204 std::unordered_map< Key, Value, hash, equal_to >
206 > RefinableMap_hashmap;
208 typedef RefinableHashMap_ord<
209 boost::unordered_map< Key, Value, hash, equal_to >
211 > RefinableMap_boost_unordered_map;
213 # if BOOST_VERSION >= 104800
214 typedef RefinableHashMap_seq<
215 boost::container::list< std::pair< Key const, Value > >
218 > RefinableMap_boost_list;
220 typedef RefinableHashMap_ord<
221 boost::container::map< Key, Value, less >
223 > RefinableMap_boost_map;
225 typedef RefinableHashMap_ord<
226 boost::container::flat_map< Key, Value, less >
228 > RefinableMap_boost_flat_map;
229 # endif // #if BOOST_VERSION >= 104800
234 #endif // ifndef CDSUNIT_MAP_TYPE_MICHAEL_H