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 struct tag_StripedMap;
25 template <typename Key, typename Value>
26 struct map_type< tag_StripedMap, Key, Value >: public map_type_base< Key, Value >
28 typedef map_type_base< Key, Value > base_class;
29 typedef typename base_class::compare compare;
30 typedef typename base_class::less less;
31 typedef typename base_class::equal_to equal_to;
32 typedef typename base_class::key_hash key_hash;
33 typedef typename base_class::hash hash;
34 typedef typename base_class::hash2 hash2;
36 // for sequential containers
37 template <class BucketEntry, typename... Options>
38 class StripedHashMap_seq:
39 public cc::StripedMap< BucketEntry,
40 co::mutex_policy< cc::striped_set::striping<> >
41 ,co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
45 typedef cc::StripedMap< BucketEntry,
46 co::mutex_policy< cc::striped_set::striping<> >
47 ,co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
50 typedef typename base_class::resizing_policy resizing_policy_t;
52 resizing_policy_t m_placeHolder;
54 template <class Config>
55 StripedHashMap_seq( Config const& cfg )
56 : base_class( cfg.c_nMapSize / cfg.c_nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( cfg.c_nLoadFactor )) )
60 static CDS_CONSTEXPR bool const c_bExtractSupported = false;
61 static CDS_CONSTEXPR bool const c_bLoadFactorDepended = true;
64 // for non-sequential ordered containers
65 template <class BucketEntry, typename... Options>
66 class StripedHashMap_ord:
67 public cc::StripedMap< BucketEntry,
68 co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
69 ,co::mutex_policy< cc::striped_set::striping<> >
73 typedef cc::StripedMap< BucketEntry,
74 co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
75 ,co::mutex_policy< cc::striped_set::striping<> >
78 typedef typename base_class::resizing_policy resizing_policy_t;
80 resizing_policy_t m_placeHolder;
82 template <class Config>
83 StripedHashMap_ord( Config const& cfg )
84 : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( cfg.c_nMaxLoadFactor * 1024 )) )
88 static CDS_CONSTEXPR bool const c_bExtractSupported = false;
89 static CDS_CONSTEXPR bool const c_bLoadFactorDepended = false;
93 typedef StripedHashMap_seq<
94 std::list< std::pair< Key const, Value > >
99 # if (CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600
100 typedef StripedHashMap_ord<
101 stdext::hash_map< Key, Value, stdext::hash_compare<Key, less > >
103 > StripedMap_hashmap;
105 typedef StripedHashMap_ord<
106 std::unordered_map< Key, Value, hash, equal_to >
108 > StripedMap_hashmap;
111 typedef StripedHashMap_ord<
112 std::map< Key, Value, less >
116 typedef StripedHashMap_ord<
117 boost::unordered_map< Key, Value, hash, equal_to >
119 > StripedMap_boost_unordered_map;
121 # if BOOST_VERSION >= 104800
122 typedef StripedHashMap_seq<
123 boost::container::slist< std::pair< Key const, Value > >
128 typedef StripedHashMap_seq<
129 boost::container::list< std::pair< Key const, Value > >
132 > StripedMap_boost_list;
134 typedef StripedHashMap_ord<
135 boost::container::map< Key, Value, less >
137 > StripedMap_boost_map;
139 typedef StripedHashMap_ord<
140 boost::container::flat_map< Key, Value, less >
142 > StripedMap_boost_flat_map;
143 # endif // BOOST_VERSION >= 104800
146 // ***************************************************************************
149 // for sequential containers
150 template <class BucketEntry, typename... Options>
151 class RefinableHashMap_seq:
152 public cc::StripedMap< BucketEntry,
153 co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
154 ,co::mutex_policy< cc::striped_set::refinable<> >
158 typedef cc::StripedMap< BucketEntry,
159 co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
160 ,co::mutex_policy< cc::striped_set::refinable<> >
163 typedef typename base_class::resizing_policy resizing_policy_t;
165 resizing_policy_t m_placeHolder;
167 template <class Config>
168 RefinableHashMap_seq( Config const& cfg )
169 : base_class( cfg.c_nMapSize / cfg.c_nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( cfg.c_nLoadFactor )))
173 static CDS_CONSTEXPR bool const c_bExtractSupported = false;
174 static CDS_CONSTEXPR bool const c_bLoadFactorDepended = true;
177 // for non-sequential ordered containers
178 template <class BucketEntry, typename... Options>
179 class RefinableHashMap_ord:
180 public cc::StripedMap< BucketEntry,
181 co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
182 ,co::mutex_policy< cc::striped_set::refinable<> >
186 typedef cc::StripedMap< BucketEntry,
187 co::resizing_policy<cc::striped_set::load_factor_resizing<0> >
188 ,co::mutex_policy< cc::striped_set::refinable<> >
191 typedef typename base_class::resizing_policy resizing_policy_t;
193 resizing_policy_t m_placeHolder;
195 template <class Config>
196 RefinableHashMap_ord( Config const& cfg )
197 : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( cfg.c_nMaxLoadFactor * 1024 )) )
201 static CDS_CONSTEXPR bool const c_bExtractSupported = false;
202 static CDS_CONSTEXPR bool const c_bLoadFactorDepended = false;
206 typedef RefinableHashMap_seq<
207 std::list< std::pair< Key const, Value > >
212 # if BOOST_VERSION >= 104800
213 typedef RefinableHashMap_seq<
214 boost::container::slist< std::pair< Key const, Value > >
217 > RefinableMap_slist;
220 typedef RefinableHashMap_ord<
221 std::map< Key, Value, less >
225 typedef RefinableHashMap_ord<
226 std::unordered_map< Key, Value, hash, equal_to >
228 > RefinableMap_hashmap;
230 typedef RefinableHashMap_ord<
231 boost::unordered_map< Key, Value, hash, equal_to >
233 > RefinableMap_boost_unordered_map;
235 # if BOOST_VERSION >= 104800
236 typedef RefinableHashMap_seq<
237 boost::container::list< std::pair< Key const, Value > >
240 > RefinableMap_boost_list;
242 typedef RefinableHashMap_ord<
243 boost::container::map< Key, Value, less >
245 > RefinableMap_boost_map;
247 typedef RefinableHashMap_ord<
248 boost::container::flat_map< Key, Value, less >
250 > RefinableMap_boost_flat_map;
251 # endif // #if BOOST_VERSION >= 104800
256 #endif // ifndef CDSUNIT_MAP_TYPE_MICHAEL_H