3 #ifndef CDSUNIT_MAP_TYPE_FELDMAN_HASHMAP_H
4 #define CDSUNIT_MAP_TYPE_FELDMAN_HASHMAP_H
6 #include "map2/map_type.h"
8 #include <cds/container/feldman_hashmap_hp.h>
9 #include <cds/container/feldman_hashmap_dhp.h>
10 #include <cds/container/feldman_hashmap_rcu.h>
12 #include "print_feldman_hashset_stat.h"
13 #include "hashing/hash_func.h"
17 template <class GC, typename Key, typename T, typename Traits = cc::feldman_hashmap::traits>
18 class FeldmanHashMap : public cc::FeldmanHashMap< GC, Key, T, Traits >
20 typedef cc::FeldmanHashMap< GC, Key, T, Traits > base_class;
22 template <typename Config>
23 FeldmanHashMap( Config const& cfg)
24 : base_class( cfg.c_nFeldmanMap_HeadBits, cfg.c_nFeldmanMap_ArrayBits )
28 static CDS_CONSTEXPR bool const c_bExtractSupported = true;
29 static CDS_CONSTEXPR bool const c_bLoadFactorDepended = false;
30 static CDS_CONSTEXPR bool const c_bEraseExactKey = true;
33 struct tag_FeldmanHashMap;
35 template <typename Key, typename Value>
36 struct map_type< tag_FeldmanHashMap, Key, Value >: public map_type_base< Key, Value >
38 typedef map_type_base< Key, Value > base_class;
39 typedef typename base_class::compare compare;
40 typedef typename base_class::less less;
42 struct traits_FeldmanHashMap_stdhash : public cc::feldman_hashmap::traits
44 typedef std::hash< Key > hash;
47 typedef FeldmanHashMap< cds::gc::HP, Key, Value, traits_FeldmanHashMap_stdhash > FeldmanHashMap_hp_stdhash;
48 typedef FeldmanHashMap< cds::gc::DHP, Key, Value, traits_FeldmanHashMap_stdhash > FeldmanHashMap_dhp_stdhash;
49 typedef FeldmanHashMap< rcu_gpi, Key, Value, traits_FeldmanHashMap_stdhash > FeldmanHashMap_rcu_gpi_stdhash;
50 typedef FeldmanHashMap< rcu_gpb, Key, Value, traits_FeldmanHashMap_stdhash > FeldmanHashMap_rcu_gpb_stdhash;
51 typedef FeldmanHashMap< rcu_gpt, Key, Value, traits_FeldmanHashMap_stdhash > FeldmanHashMap_rcu_gpt_stdhash;
52 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
53 typedef FeldmanHashMap< rcu_shb, Key, Value, traits_FeldmanHashMap_stdhash > FeldmanHashMap_rcu_shb_stdhash;
54 typedef FeldmanHashMap< rcu_sht, Key, Value, traits_FeldmanHashMap_stdhash > FeldmanHashMap_rcu_sht_stdhash;
57 struct traits_FeldmanHashMap_stdhash_stat: traits_FeldmanHashMap_stdhash
59 typedef cc::feldman_hashmap::stat<> stat;
62 typedef FeldmanHashMap< cds::gc::HP, Key, Value, traits_FeldmanHashMap_stdhash_stat > FeldmanHashMap_hp_stdhash_stat;
63 typedef FeldmanHashMap< cds::gc::DHP, Key, Value, traits_FeldmanHashMap_stdhash_stat > FeldmanHashMap_dhp_stdhash_stat;
64 typedef FeldmanHashMap< rcu_gpi, Key, Value, traits_FeldmanHashMap_stdhash_stat > FeldmanHashMap_rcu_gpi_stdhash_stat;
65 typedef FeldmanHashMap< rcu_gpb, Key, Value, traits_FeldmanHashMap_stdhash_stat > FeldmanHashMap_rcu_gpb_stdhash_stat;
66 typedef FeldmanHashMap< rcu_gpt, Key, Value, traits_FeldmanHashMap_stdhash_stat > FeldmanHashMap_rcu_gpt_stdhash_stat;
67 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
68 typedef FeldmanHashMap< rcu_shb, Key, Value, traits_FeldmanHashMap_stdhash_stat > FeldmanHashMap_rcu_shb_stdhash_stat;
69 typedef FeldmanHashMap< rcu_sht, Key, Value, traits_FeldmanHashMap_stdhash_stat > FeldmanHashMap_rcu_sht_stdhash_stat;
73 struct traits_FeldmanHashMap_sha256 : public cc::feldman_hashmap::traits
75 typedef ::hashing::sha256 hash;
77 typedef FeldmanHashMap< cds::gc::HP, Key, Value, traits_FeldmanHashMap_sha256 > FeldmanHashMap_hp_sha256;
78 typedef FeldmanHashMap< cds::gc::DHP, Key, Value, traits_FeldmanHashMap_sha256 > FeldmanHashMap_dhp_sha256;
79 typedef FeldmanHashMap< rcu_gpi, Key, Value, traits_FeldmanHashMap_sha256 > FeldmanHashMap_rcu_gpi_sha256;
80 typedef FeldmanHashMap< rcu_gpb, Key, Value, traits_FeldmanHashMap_sha256 > FeldmanHashMap_rcu_gpb_sha256;
81 typedef FeldmanHashMap< rcu_gpt, Key, Value, traits_FeldmanHashMap_sha256 > FeldmanHashMap_rcu_gpt_sha256;
82 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
83 typedef FeldmanHashMap< rcu_shb, Key, Value, traits_FeldmanHashMap_sha256 > FeldmanHashMap_rcu_shb_sha256;
84 typedef FeldmanHashMap< rcu_sht, Key, Value, traits_FeldmanHashMap_sha256 > FeldmanHashMap_rcu_sht_sha256;
87 struct traits_FeldmanHashMap_sha256_stat : public traits_FeldmanHashMap_sha256
89 typedef cc::feldman_hashmap::stat<> stat;
91 typedef FeldmanHashMap< cds::gc::HP, Key, Value, traits_FeldmanHashMap_sha256_stat > FeldmanHashMap_hp_sha256_stat;
92 typedef FeldmanHashMap< cds::gc::DHP, Key, Value, traits_FeldmanHashMap_sha256_stat > FeldmanHashMap_dhp_sha256_stat;
93 typedef FeldmanHashMap< rcu_gpi, Key, Value, traits_FeldmanHashMap_sha256_stat > FeldmanHashMap_rcu_gpi_sha256_stat;
94 typedef FeldmanHashMap< rcu_gpb, Key, Value, traits_FeldmanHashMap_sha256_stat > FeldmanHashMap_rcu_gpb_sha256_stat;
95 typedef FeldmanHashMap< rcu_gpt, Key, Value, traits_FeldmanHashMap_sha256_stat > FeldmanHashMap_rcu_gpt_sha256_stat;
96 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
97 typedef FeldmanHashMap< rcu_shb, Key, Value, traits_FeldmanHashMap_sha256_stat > FeldmanHashMap_rcu_shb_sha256_stat;
98 typedef FeldmanHashMap< rcu_sht, Key, Value, traits_FeldmanHashMap_sha256_stat > FeldmanHashMap_rcu_sht_sha256_stat;
102 struct traits_FeldmanHashMap_md5 : public cc::feldman_hashmap::traits
104 typedef ::hashing::md5 hash;
106 typedef FeldmanHashMap< cds::gc::HP, Key, Value, traits_FeldmanHashMap_md5 > FeldmanHashMap_hp_md5;
107 typedef FeldmanHashMap< cds::gc::DHP, Key, Value, traits_FeldmanHashMap_md5 > FeldmanHashMap_dhp_md5;
108 typedef FeldmanHashMap< rcu_gpi, Key, Value, traits_FeldmanHashMap_md5 > FeldmanHashMap_rcu_gpi_md5;
109 typedef FeldmanHashMap< rcu_gpb, Key, Value, traits_FeldmanHashMap_md5 > FeldmanHashMap_rcu_gpb_md5;
110 typedef FeldmanHashMap< rcu_gpt, Key, Value, traits_FeldmanHashMap_md5 > FeldmanHashMap_rcu_gpt_md5;
111 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
112 typedef FeldmanHashMap< rcu_shb, Key, Value, traits_FeldmanHashMap_md5 > FeldmanHashMap_rcu_shb_md5;
113 typedef FeldmanHashMap< rcu_sht, Key, Value, traits_FeldmanHashMap_md5 > FeldmanHashMap_rcu_sht_md5;
116 struct traits_FeldmanHashMap_md5_stat : public traits_FeldmanHashMap_md5
118 typedef cc::feldman_hashmap::stat<> stat;
120 typedef FeldmanHashMap< cds::gc::HP, Key, Value, traits_FeldmanHashMap_md5_stat > FeldmanHashMap_hp_md5_stat;
121 typedef FeldmanHashMap< cds::gc::DHP, Key, Value, traits_FeldmanHashMap_md5_stat > FeldmanHashMap_dhp_md5_stat;
122 typedef FeldmanHashMap< rcu_gpi, Key, Value, traits_FeldmanHashMap_md5_stat > FeldmanHashMap_rcu_gpi_md5_stat;
123 typedef FeldmanHashMap< rcu_gpb, Key, Value, traits_FeldmanHashMap_md5_stat > FeldmanHashMap_rcu_gpb_md5_stat;
124 typedef FeldmanHashMap< rcu_gpt, Key, Value, traits_FeldmanHashMap_md5_stat > FeldmanHashMap_rcu_gpt_md5_stat;
125 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
126 typedef FeldmanHashMap< rcu_shb, Key, Value, traits_FeldmanHashMap_md5_stat > FeldmanHashMap_rcu_shb_md5_stat;
127 typedef FeldmanHashMap< rcu_sht, Key, Value, traits_FeldmanHashMap_md5_stat > FeldmanHashMap_rcu_sht_md5_stat;
131 #if CDS_BUILD_BITS == 64
132 struct traits_FeldmanHashMap_city64 : public cc::feldman_hashmap::traits
134 typedef ::hashing::city64 hash;
135 typedef ::hashing::city64::less less;
137 typedef FeldmanHashMap< cds::gc::HP, Key, Value, traits_FeldmanHashMap_city64 > FeldmanHashMap_hp_city64;
138 typedef FeldmanHashMap< cds::gc::DHP, Key, Value, traits_FeldmanHashMap_city64 > FeldmanHashMap_dhp_city64;
139 typedef FeldmanHashMap< rcu_gpi, Key, Value, traits_FeldmanHashMap_city64 > FeldmanHashMap_rcu_gpi_city64;
140 typedef FeldmanHashMap< rcu_gpb, Key, Value, traits_FeldmanHashMap_city64 > FeldmanHashMap_rcu_gpb_city64;
141 typedef FeldmanHashMap< rcu_gpt, Key, Value, traits_FeldmanHashMap_city64 > FeldmanHashMap_rcu_gpt_city64;
142 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
143 typedef FeldmanHashMap< rcu_shb, Key, Value, traits_FeldmanHashMap_city64 > FeldmanHashMap_rcu_shb_city64;
144 typedef FeldmanHashMap< rcu_sht, Key, Value, traits_FeldmanHashMap_city64 > FeldmanHashMap_rcu_sht_city64;
147 struct traits_FeldmanHashMap_city64_stat : public traits_FeldmanHashMap_city64
149 typedef cc::feldman_hashmap::stat<> stat;
151 typedef FeldmanHashMap< cds::gc::HP, Key, Value, traits_FeldmanHashMap_city64_stat > FeldmanHashMap_hp_city64_stat;
152 typedef FeldmanHashMap< cds::gc::DHP, Key, Value, traits_FeldmanHashMap_city64_stat > FeldmanHashMap_dhp_city64_stat;
153 typedef FeldmanHashMap< rcu_gpi, Key, Value, traits_FeldmanHashMap_city64_stat > FeldmanHashMap_rcu_gpi_city64_stat;
154 typedef FeldmanHashMap< rcu_gpb, Key, Value, traits_FeldmanHashMap_city64_stat > FeldmanHashMap_rcu_gpb_city64_stat;
155 typedef FeldmanHashMap< rcu_gpt, Key, Value, traits_FeldmanHashMap_city64_stat > FeldmanHashMap_rcu_gpt_city64_stat;
156 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
157 typedef FeldmanHashMap< rcu_shb, Key, Value, traits_FeldmanHashMap_city64_stat > FeldmanHashMap_rcu_shb_city64_stat;
158 typedef FeldmanHashMap< rcu_sht, Key, Value, traits_FeldmanHashMap_city64_stat > FeldmanHashMap_rcu_sht_city64_stat;
161 struct traits_FeldmanHashMap_city128 : public cc::feldman_hashmap::traits
163 typedef ::hashing::city128 hash;
164 typedef ::hashing::city128::less less;
166 typedef FeldmanHashMap< cds::gc::HP, Key, Value, traits_FeldmanHashMap_city128 > FeldmanHashMap_hp_city128;
167 typedef FeldmanHashMap< cds::gc::DHP, Key, Value, traits_FeldmanHashMap_city128 > FeldmanHashMap_dhp_city128;
168 typedef FeldmanHashMap< rcu_gpi, Key, Value, traits_FeldmanHashMap_city128 > FeldmanHashMap_rcu_gpi_city128;
169 typedef FeldmanHashMap< rcu_gpb, Key, Value, traits_FeldmanHashMap_city128 > FeldmanHashMap_rcu_gpb_city128;
170 typedef FeldmanHashMap< rcu_gpt, Key, Value, traits_FeldmanHashMap_city128 > FeldmanHashMap_rcu_gpt_city128;
171 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
172 typedef FeldmanHashMap< rcu_shb, Key, Value, traits_FeldmanHashMap_city128 > FeldmanHashMap_rcu_shb_city128;
173 typedef FeldmanHashMap< rcu_sht, Key, Value, traits_FeldmanHashMap_city128 > FeldmanHashMap_rcu_sht_city128;
176 struct traits_FeldmanHashMap_city128_stat : public traits_FeldmanHashMap_city128
178 typedef cc::feldman_hashmap::stat<> stat;
180 typedef FeldmanHashMap< cds::gc::HP, Key, Value, traits_FeldmanHashMap_city128_stat > FeldmanHashMap_hp_city128_stat;
181 typedef FeldmanHashMap< cds::gc::DHP, Key, Value, traits_FeldmanHashMap_city128_stat > FeldmanHashMap_dhp_city128_stat;
182 typedef FeldmanHashMap< rcu_gpi, Key, Value, traits_FeldmanHashMap_city128_stat > FeldmanHashMap_rcu_gpi_city128_stat;
183 typedef FeldmanHashMap< rcu_gpb, Key, Value, traits_FeldmanHashMap_city128_stat > FeldmanHashMap_rcu_gpb_city128_stat;
184 typedef FeldmanHashMap< rcu_gpt, Key, Value, traits_FeldmanHashMap_city128_stat > FeldmanHashMap_rcu_gpt_city128_stat;
185 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
186 typedef FeldmanHashMap< rcu_shb, Key, Value, traits_FeldmanHashMap_city128_stat > FeldmanHashMap_rcu_shb_city128_stat;
187 typedef FeldmanHashMap< rcu_sht, Key, Value, traits_FeldmanHashMap_city128_stat > FeldmanHashMap_rcu_sht_city128_stat;
189 #endif // CDS_BUILD_BITS == 64
192 // for fixed-sized keys - no hash functor required
193 typedef FeldmanHashMap< cds::gc::HP, Key, Value > FeldmanHashMap_hp_fixed;
194 typedef FeldmanHashMap< cds::gc::DHP, Key, Value > FeldmanHashMap_dhp_fixed;
195 typedef FeldmanHashMap< rcu_gpi, Key, Value > FeldmanHashMap_rcu_gpi_fixed;
196 typedef FeldmanHashMap< rcu_gpb, Key, Value > FeldmanHashMap_rcu_gpb_fixed;
197 typedef FeldmanHashMap< rcu_gpt, Key, Value > FeldmanHashMap_rcu_gpt_fixed;
198 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
199 typedef FeldmanHashMap< rcu_shb, Key, Value > FeldmanHashMap_rcu_shb_fixed;
200 typedef FeldmanHashMap< rcu_sht, Key, Value > FeldmanHashMap_rcu_sht_fixed;
203 struct traits_FeldmanHashMap_stat : public cc::feldman_hashmap::traits
205 typedef cc::feldman_hashmap::stat<> stat;
207 typedef FeldmanHashMap< cds::gc::HP, Key, Value, traits_FeldmanHashMap_stat > FeldmanHashMap_hp_fixed_stat;
208 typedef FeldmanHashMap< cds::gc::DHP, Key, Value, traits_FeldmanHashMap_stat > FeldmanHashMap_dhp_fixed_stat;
209 typedef FeldmanHashMap< rcu_gpi, Key, Value, traits_FeldmanHashMap_stat > FeldmanHashMap_rcu_gpi_fixed_stat;
210 typedef FeldmanHashMap< rcu_gpb, Key, Value, traits_FeldmanHashMap_stat > FeldmanHashMap_rcu_gpb_fixed_stat;
211 typedef FeldmanHashMap< rcu_gpt, Key, Value, traits_FeldmanHashMap_stat > FeldmanHashMap_rcu_gpt_fixed_stat;
212 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
213 typedef FeldmanHashMap< rcu_shb, Key, Value, traits_FeldmanHashMap_stat > FeldmanHashMap_rcu_shb_fixed_stat;
214 typedef FeldmanHashMap< rcu_sht, Key, Value, traits_FeldmanHashMap_stat > FeldmanHashMap_rcu_sht_fixed_stat;
219 template <typename GC, typename K, typename T, typename Traits >
220 static inline void print_stat( FeldmanHashMap< GC, K, T, Traits > const& m )
222 CPPUNIT_MSG( m.statistics() );
227 #endif // #ifndef CDSUNIT_MAP_TYPE_FELDMAN_HASHMAP_H