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 #if CDS_BUILD_BITS == 64
74 struct traits_FeldmanHashMap_city64 : public cc::feldman_hashmap::traits
76 typedef ::hashing::city64 hash;
77 typedef ::hashing::city64::less less;
79 typedef FeldmanHashMap< cds::gc::HP, Key, Value, traits_FeldmanHashMap_city64 > FeldmanHashMap_hp_city64;
80 typedef FeldmanHashMap< cds::gc::DHP, Key, Value, traits_FeldmanHashMap_city64 > FeldmanHashMap_dhp_city64;
81 typedef FeldmanHashMap< rcu_gpi, Key, Value, traits_FeldmanHashMap_city64 > FeldmanHashMap_rcu_gpi_city64;
82 typedef FeldmanHashMap< rcu_gpb, Key, Value, traits_FeldmanHashMap_city64 > FeldmanHashMap_rcu_gpb_city64;
83 typedef FeldmanHashMap< rcu_gpt, Key, Value, traits_FeldmanHashMap_city64 > FeldmanHashMap_rcu_gpt_city64;
84 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
85 typedef FeldmanHashMap< rcu_shb, Key, Value, traits_FeldmanHashMap_city64 > FeldmanHashMap_rcu_shb_city64;
86 typedef FeldmanHashMap< rcu_sht, Key, Value, traits_FeldmanHashMap_city64 > FeldmanHashMap_rcu_sht_city64;
89 struct traits_FeldmanHashMap_city64_stat : public traits_FeldmanHashMap_city64
91 typedef cc::feldman_hashmap::stat<> stat;
93 typedef FeldmanHashMap< cds::gc::HP, Key, Value, traits_FeldmanHashMap_city64_stat > FeldmanHashMap_hp_city64_stat;
94 typedef FeldmanHashMap< cds::gc::DHP, Key, Value, traits_FeldmanHashMap_city64_stat > FeldmanHashMap_dhp_city64_stat;
95 typedef FeldmanHashMap< rcu_gpi, Key, Value, traits_FeldmanHashMap_city64_stat > FeldmanHashMap_rcu_gpi_city64_stat;
96 typedef FeldmanHashMap< rcu_gpb, Key, Value, traits_FeldmanHashMap_city64_stat > FeldmanHashMap_rcu_gpb_city64_stat;
97 typedef FeldmanHashMap< rcu_gpt, Key, Value, traits_FeldmanHashMap_city64_stat > FeldmanHashMap_rcu_gpt_city64_stat;
98 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
99 typedef FeldmanHashMap< rcu_shb, Key, Value, traits_FeldmanHashMap_city64_stat > FeldmanHashMap_rcu_shb_city64_stat;
100 typedef FeldmanHashMap< rcu_sht, Key, Value, traits_FeldmanHashMap_city64_stat > FeldmanHashMap_rcu_sht_city64_stat;
103 struct traits_FeldmanHashMap_city128 : public cc::feldman_hashmap::traits
105 typedef ::hashing::city128 hash;
106 typedef ::hashing::city128::less less;
108 typedef FeldmanHashMap< cds::gc::HP, Key, Value, traits_FeldmanHashMap_city128 > FeldmanHashMap_hp_city128;
109 typedef FeldmanHashMap< cds::gc::DHP, Key, Value, traits_FeldmanHashMap_city128 > FeldmanHashMap_dhp_city128;
110 typedef FeldmanHashMap< rcu_gpi, Key, Value, traits_FeldmanHashMap_city128 > FeldmanHashMap_rcu_gpi_city128;
111 typedef FeldmanHashMap< rcu_gpb, Key, Value, traits_FeldmanHashMap_city128 > FeldmanHashMap_rcu_gpb_city128;
112 typedef FeldmanHashMap< rcu_gpt, Key, Value, traits_FeldmanHashMap_city128 > FeldmanHashMap_rcu_gpt_city128;
113 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
114 typedef FeldmanHashMap< rcu_shb, Key, Value, traits_FeldmanHashMap_city128 > FeldmanHashMap_rcu_shb_city128;
115 typedef FeldmanHashMap< rcu_sht, Key, Value, traits_FeldmanHashMap_city128 > FeldmanHashMap_rcu_sht_city128;
118 struct traits_FeldmanHashMap_city128_stat : public traits_FeldmanHashMap_city128
120 typedef cc::feldman_hashmap::stat<> stat;
122 typedef FeldmanHashMap< cds::gc::HP, Key, Value, traits_FeldmanHashMap_city128_stat > FeldmanHashMap_hp_city128_stat;
123 typedef FeldmanHashMap< cds::gc::DHP, Key, Value, traits_FeldmanHashMap_city128_stat > FeldmanHashMap_dhp_city128_stat;
124 typedef FeldmanHashMap< rcu_gpi, Key, Value, traits_FeldmanHashMap_city128_stat > FeldmanHashMap_rcu_gpi_city128_stat;
125 typedef FeldmanHashMap< rcu_gpb, Key, Value, traits_FeldmanHashMap_city128_stat > FeldmanHashMap_rcu_gpb_city128_stat;
126 typedef FeldmanHashMap< rcu_gpt, Key, Value, traits_FeldmanHashMap_city128_stat > FeldmanHashMap_rcu_gpt_city128_stat;
127 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
128 typedef FeldmanHashMap< rcu_shb, Key, Value, traits_FeldmanHashMap_city128_stat > FeldmanHashMap_rcu_shb_city128_stat;
129 typedef FeldmanHashMap< rcu_sht, Key, Value, traits_FeldmanHashMap_city128_stat > FeldmanHashMap_rcu_sht_city128_stat;
131 #endif // CDS_BUILD_BITS == 64
134 // for fixed-sized keys - no hash functor required
135 typedef FeldmanHashMap< cds::gc::HP, Key, Value > FeldmanHashMap_hp_fixed;
136 typedef FeldmanHashMap< cds::gc::DHP, Key, Value > FeldmanHashMap_dhp_fixed;
137 typedef FeldmanHashMap< rcu_gpi, Key, Value > FeldmanHashMap_rcu_gpi_fixed;
138 typedef FeldmanHashMap< rcu_gpb, Key, Value > FeldmanHashMap_rcu_gpb_fixed;
139 typedef FeldmanHashMap< rcu_gpt, Key, Value > FeldmanHashMap_rcu_gpt_fixed;
140 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
141 typedef FeldmanHashMap< rcu_shb, Key, Value > FeldmanHashMap_rcu_shb_fixed;
142 typedef FeldmanHashMap< rcu_sht, Key, Value > FeldmanHashMap_rcu_sht_fixed;
145 struct traits_FeldmanHashMap_stat : public cc::feldman_hashmap::traits
147 typedef cc::feldman_hashmap::stat<> stat;
149 typedef FeldmanHashMap< cds::gc::HP, Key, Value, traits_FeldmanHashMap_stat > FeldmanHashMap_hp_fixed_stat;
150 typedef FeldmanHashMap< cds::gc::DHP, Key, Value, traits_FeldmanHashMap_stat > FeldmanHashMap_dhp_fixed_stat;
151 typedef FeldmanHashMap< rcu_gpi, Key, Value, traits_FeldmanHashMap_stat > FeldmanHashMap_rcu_gpi_fixed_stat;
152 typedef FeldmanHashMap< rcu_gpb, Key, Value, traits_FeldmanHashMap_stat > FeldmanHashMap_rcu_gpb_fixed_stat;
153 typedef FeldmanHashMap< rcu_gpt, Key, Value, traits_FeldmanHashMap_stat > FeldmanHashMap_rcu_gpt_fixed_stat;
154 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
155 typedef FeldmanHashMap< rcu_shb, Key, Value, traits_FeldmanHashMap_stat > FeldmanHashMap_rcu_shb_fixed_stat;
156 typedef FeldmanHashMap< rcu_sht, Key, Value, traits_FeldmanHashMap_stat > FeldmanHashMap_rcu_sht_fixed_stat;
161 template <typename GC, typename K, typename T, typename Traits >
162 static inline void print_stat( FeldmanHashMap< GC, K, T, Traits > const& m )
164 CPPUNIT_MSG( m.statistics() );
166 std::vector< cds::intrusive::feldman_hashset::level_statistics > level_stat;
167 m.get_level_statistics( level_stat );
168 CPPUNIT_MSG( level_stat );
173 #endif // #ifndef CDSUNIT_MAP_TYPE_FELDMAN_HASHMAP_H