Refactored MapDelOdd MT-test
[libcds.git] / tests / unit / map2 / map_type_multilevel_hashmap.h
1 //$$CDS-header$$
2
3 #ifndef CDSUNIT_MAP_TYPE_MULTILEVEL_HASHMAP_H
4 #define CDSUNIT_MAP_TYPE_MULTILEVEL_HASHMAP_H
5
6 #include "map2/map_type.h"
7
8 #include <cds/container/multilevel_hashmap_hp.h>
9 #include <cds/container/multilevel_hashmap_dhp.h>
10
11 #include "print_multilevel_hashset_stat.h"
12
13 namespace map2 {
14
15     template <class GC, typename Key, typename T, typename Traits = cc::multilevel_hashmap::traits>
16     class MultiLevelHashMap : public cc::MultiLevelHashMap< GC, Key, T, Traits >
17     {
18         typedef cc::MultiLevelHashMap< GC, Key, T, Traits > base_class;
19     public:
20         template <typename Config>
21         MultiLevelHashMap( Config const& cfg)
22             : base_class( cfg.c_nMultiLevelMap_HeadBits, cfg.c_nMultiLevelMap_ArrayBits )
23         {}
24
25         // for testing
26         static CDS_CONSTEXPR bool const c_bExtractSupported = true;
27         static CDS_CONSTEXPR bool const c_bLoadFactorDepended = false;
28     };
29
30     struct tag_MultiLevelHashMap;
31
32     template <typename Key, typename Value>
33     struct map_type< tag_MultiLevelHashMap, Key, Value >: public map_type_base< Key, Value >
34     {
35         typedef map_type_base< Key, Value > base_class;
36         typedef typename base_class::compare    compare;
37         typedef typename base_class::less       less;
38
39         typedef MultiLevelHashMap< cds::gc::HP,  Key, Value >    MultiLevelHashMap_hp_stdhash;
40         typedef MultiLevelHashMap< cds::gc::DHP, Key, Value >    MultiLevelHashMap_dhp_stdhash;
41
42         struct traits_MultiLevelHashMap_stat: public cc::multilevel_hashmap::make_traits<
43                 co::stat< cc::multilevel_hashmap::stat<>>
44             >::type
45         {};
46
47         typedef MultiLevelHashMap< cds::gc::HP,  Key, Value, traits_MultiLevelHashMap_stat >    MultiLevelHashMap_hp_stdhash_stat;
48         typedef MultiLevelHashMap< cds::gc::DHP, Key, Value, traits_MultiLevelHashMap_stat >    MultiLevelHashMap_dhp_stdhash_stat;
49     };
50
51     template <typename GC, typename K, typename T, typename Traits >
52     static inline void print_stat( cc::MultiLevelHashMap< GC, K, T, Traits > const& m )
53     {
54         CPPUNIT_MSG( m.statistics() );
55     }
56
57 }   // namespace map2
58
59 #endif // #ifndef CDSUNIT_MAP_TYPE_MULTILEVEL_HASHMAP_H