SplitListMap refactoring
[libcds.git] / tests / test-hdr / map / hdr_splitlist_map_dhp.cpp
1 //$$CDS-header$$
2
3 #include "map/hdr_map.h"
4 #include <cds/container/michael_list_dhp.h>
5 #include <cds/container/split_list_map.h>
6
7 namespace map {
8
9     namespace {
10         struct DHP_cmp_traits: public cc::split_list::traits
11         {
12             typedef cc::michael_list_tag                ordered_list;
13             typedef HashMapHdrTest::hash_int            hash;
14             typedef HashMapHdrTest::simple_item_counter item_counter;
15             typedef cc::opt::v::relaxed_ordering        memory_model;
16             enum { dynamic_bucket_table = false };
17
18             struct ordered_list_traits: public cc::michael_list::traits
19             {
20                 typedef HashMapHdrTest::cmp   compare;
21             };
22         };
23
24         struct DHP_less_traits: public cc::split_list::traits
25         {
26             typedef cc::michael_list_tag                ordered_list;
27             typedef HashMapHdrTest::hash_int            hash;
28             typedef HashMapHdrTest::simple_item_counter item_counter;
29             typedef cc::opt::v::sequential_consistent                      memory_model;
30             enum { dynamic_bucket_table = true };
31
32             struct ordered_list_traits: public cc::michael_list::traits
33             {
34                 typedef HashMapHdrTest::less   less;
35             };
36         };
37
38         struct DHP_cmpmix_traits: public cc::split_list::traits
39         {
40             typedef cc::michael_list_tag                ordered_list;
41             typedef HashMapHdrTest::hash_int            hash;
42             typedef HashMapHdrTest::simple_item_counter item_counter;
43
44             struct ordered_list_traits: public cc::michael_list::traits
45             {
46                 typedef HashMapHdrTest::cmp   compare;
47                 typedef std::less<HashMapHdrTest::key_type>     less;
48             };
49         };
50
51         struct DHP_cmpmix_stat_traits : public DHP_cmpmix_traits
52         {
53             typedef cc::split_list::stat<> stat;
54         };
55     }
56
57     void HashMapHdrTest::Split_DHP_cmp()
58     {
59         // traits-based version
60         typedef cc::SplitListMap< cds::gc::DHP, key_type, value_type, DHP_cmp_traits > map_type;
61         test_int< map_type >();
62
63         // option-based version
64         typedef cc::SplitListMap< cds::gc::DHP,
65             key_type,
66             value_type,
67             cc::split_list::make_traits<
68                 cc::split_list::ordered_list<cc::michael_list_tag>
69                 ,cc::opt::hash< hash_int >
70                 ,cc::opt::item_counter< simple_item_counter >
71                 ,cc::opt::memory_model< cc::opt::v::relaxed_ordering >
72                 ,cc::split_list::dynamic_bucket_table< true >
73                 ,cc::split_list::ordered_list_traits<
74                     cc::michael_list::make_traits<
75                         cc::opt::compare< cmp >
76                     >::type
77                 >
78             >::type
79         > opt_map;
80         test_int< opt_map >();
81     }
82
83     void HashMapHdrTest::Split_DHP_less()
84     {
85         // traits-based version
86         typedef cc::SplitListMap< cds::gc::DHP, key_type, value_type, DHP_less_traits > map_type;
87         test_int< map_type >();
88
89         // option-based version
90         typedef cc::SplitListMap< cds::gc::DHP,
91             key_type,
92             value_type,
93             cc::split_list::make_traits<
94                 cc::split_list::ordered_list<cc::michael_list_tag>
95                 ,cc::opt::hash< hash_int >
96                 ,cc::opt::item_counter< simple_item_counter >
97                 ,cc::opt::memory_model< cc::opt::v::relaxed_ordering >
98                 ,cc::split_list::dynamic_bucket_table< false >
99                 ,cc::split_list::ordered_list_traits<
100                     cc::michael_list::make_traits<
101                         cc::opt::less< less >
102                     >::type
103                 >
104             >::type
105         > opt_map;
106         test_int< opt_map >();
107     }
108
109     void HashMapHdrTest::Split_DHP_cmpmix()
110     {
111         // traits-based version
112         typedef cc::SplitListMap< cds::gc::DHP, key_type, value_type, DHP_cmpmix_traits > map_type;
113         test_int< map_type >();
114
115         // option-based version
116         typedef cc::SplitListMap< cds::gc::DHP,
117             key_type,
118             value_type,
119             cc::split_list::make_traits<
120                 cc::split_list::ordered_list<cc::michael_list_tag>
121                 ,cc::opt::hash< hash_int >
122                 ,cc::opt::item_counter< simple_item_counter >
123                 ,cc::split_list::ordered_list_traits<
124                     cc::michael_list::make_traits<
125                     cc::opt::less< std::less<key_type> >
126                         ,cc::opt::compare< cmp >
127                     >::type
128                 >
129             >::type
130         > opt_map;
131         test_int< opt_map >();
132     }
133
134     void HashMapHdrTest::Split_DHP_cmpmix_stat()
135     {
136         // traits-based version
137         typedef cc::SplitListMap< cds::gc::DHP, key_type, value_type, DHP_cmpmix_stat_traits > map_type;
138         test_int< map_type >();
139
140         // option-based version
141         typedef cc::SplitListMap< cds::gc::DHP,
142             key_type,
143             value_type,
144             cc::split_list::make_traits<
145                 cc::split_list::ordered_list<cc::michael_list_tag>
146                 ,cc::opt::hash< hash_int >
147                 ,cc::opt::item_counter< simple_item_counter >
148                 ,cc::opt::stat< cc::split_list::stat<> >
149                 ,cc::split_list::ordered_list_traits<
150                     cc::michael_list::make_traits<
151                     cc::opt::less< std::less<key_type> >
152                         ,cc::opt::compare< cmp >
153                     >::type
154                 >
155             >::type
156         > opt_map;
157         test_int< opt_map >();
158     }
159
160 } // namespace map
161