MichaelList, LazyList, MichaelMap:
[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         static CDS_CONSTEXPR bool const c_erase_with_supported = false;
29         static CDS_CONSTEXPR bool const c_extract_with_supported = false;
30     };
31
32     struct tag_MultiLevelHashMap;
33
34     template <typename Key, typename Value>
35     struct map_type< map2::tag_MultiLevelHashMap, Key, Value >: public map_type_base< Key, Value >
36     {
37         typedef map_type_base< Key, Value > base_class;
38         typedef typename base_class::compare    compare;
39         typedef typename base_class::less       less;
40
41         typedef MultiLevelHashMap< cds::gc::HP,  Key, Value >    MultiLevelHashMap_hp_stdhash;
42         typedef MultiLevelHashMap< cds::gc::DHP, Key, Value >    MultiLevelHashMap_dhp_stdhash;
43
44         struct traits_MultiLevelHashMap_stat: public cc::multilevel_hashmap::make_traits<
45                 co::stat< cc::multilevel_hashmap::stat<>>
46             >::type
47         {};
48
49         typedef MultiLevelHashMap< cds::gc::HP,  Key, Value, traits_MultiLevelHashMap_stat >    MultiLevelHashMap_hp_stdhash_stat;
50         typedef MultiLevelHashMap< cds::gc::DHP, Key, Value, traits_MultiLevelHashMap_stat >    MultiLevelHashMap_dhp_stdhash_stat;
51     };
52
53     template <typename GC, typename K, typename T, typename Traits >
54     static inline void print_stat( cc::MultiLevelHashMap< GC, K, T, Traits > const& m )
55     {
56         CPPUNIT_MSG( m.statistics() );
57     }
58
59 }   // namespace map2
60
61 #endif // #ifndef CDSUNIT_MAP_TYPE_MULTILEVEL_HASHMAP_H