Move libcds 1.6.0 from SVN
[libcds.git] / tests / test-hdr / map / hdr_splitlist_map_ptb.cpp
1 //$$CDS-header$$
2
3 #include "map/hdr_map.h"
4 #include <cds/container/michael_list_ptb.h>
5 #include <cds/container/split_list_map.h>
6
7 namespace map {
8
9     namespace {
10         struct PTB_cmp_traits: public cc::split_list::type_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::type_traits
19             {
20                 typedef HashMapHdrTest::cmp   compare;
21             };
22         };
23
24         struct PTB_less_traits: public cc::split_list::type_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::type_traits
33             {
34                 typedef HashMapHdrTest::less   less;
35             };
36         };
37
38         struct PTB_cmpmix_traits: public cc::split_list::type_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::type_traits
45             {
46                 typedef HashMapHdrTest::cmp   compare;
47                 typedef std::less<HashMapHdrTest::key_type>     less;
48             };
49         };
50     }
51
52     void HashMapHdrTest::Split_PTB_cmp()
53     {
54         // traits-based version
55         typedef cc::SplitListMap< cds::gc::PTB, key_type, value_type, PTB_cmp_traits > map_type;
56         test_int< map_type >();
57
58         // option-based version
59         typedef cc::SplitListMap< cds::gc::PTB,
60             key_type,
61             value_type,
62             cc::split_list::make_traits<
63                 cc::split_list::ordered_list<cc::michael_list_tag>
64                 ,cc::opt::hash< hash_int >
65                 ,cc::opt::item_counter< simple_item_counter >
66                 ,cc::opt::memory_model< cc::opt::v::relaxed_ordering >
67                 ,cc::split_list::dynamic_bucket_table< true >
68                 ,cc::split_list::ordered_list_traits<
69                     cc::michael_list::make_traits<
70                         cc::opt::compare< cmp >
71                     >::type
72                 >
73             >::type
74         > opt_map;
75         test_int< opt_map >();
76     }
77
78     void HashMapHdrTest::Split_PTB_less()
79     {
80         // traits-based version
81         typedef cc::SplitListMap< cds::gc::PTB, key_type, value_type, PTB_less_traits > map_type;
82         test_int< map_type >();
83
84         // option-based version
85         typedef cc::SplitListMap< cds::gc::PTB,
86             key_type,
87             value_type,
88             cc::split_list::make_traits<
89                 cc::split_list::ordered_list<cc::michael_list_tag>
90                 ,cc::opt::hash< hash_int >
91                 ,cc::opt::item_counter< simple_item_counter >
92                 ,cc::opt::memory_model< cc::opt::v::relaxed_ordering >
93                 ,cc::split_list::dynamic_bucket_table< false >
94                 ,cc::split_list::ordered_list_traits<
95                     cc::michael_list::make_traits<
96                         cc::opt::less< less >
97                     >::type
98                 >
99             >::type
100         > opt_map;
101         test_int< opt_map >();
102     }
103
104     void HashMapHdrTest::Split_PTB_cmpmix()
105     {
106         // traits-based version
107         typedef cc::SplitListMap< cds::gc::PTB, key_type, value_type, PTB_cmpmix_traits > map_type;
108         test_int< map_type >();
109
110         // option-based version
111         typedef cc::SplitListMap< cds::gc::PTB,
112             key_type,
113             value_type,
114             cc::split_list::make_traits<
115                 cc::split_list::ordered_list<cc::michael_list_tag>
116                 ,cc::opt::hash< hash_int >
117                 ,cc::opt::item_counter< simple_item_counter >
118                 ,cc::split_list::ordered_list_traits<
119                     cc::michael_list::make_traits<
120                     cc::opt::less< std::less<key_type> >
121                         ,cc::opt::compare< cmp >
122                     >::type
123                 >
124             >::type
125         > opt_map;
126         test_int< opt_map >();
127     }
128
129
130 } // namespace map
131