2 This file is a part of libcds - Concurrent Data Structures library
4 (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
6 Source code repo: http://github.com/khizmax/libcds/
7 Download: http://sourceforge.net/projects/libcds/files/
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are met:
12 * Redistributions of source code must retain the above copyright notice, this
13 list of conditions and the following disclaimer.
15 * Redistributions in binary form must reproduce the above copyright notice,
16 this list of conditions and the following disclaimer in the documentation
17 and/or other materials provided with the distribution.
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "map/hdr_map.h"
32 #include <cds/container/michael_list_hp.h>
33 #include <cds/container/split_list_map.h>
38 struct HP_cmp_traits: public cc::split_list::traits
40 typedef cc::michael_list_tag ordered_list;
41 typedef HashMapHdrTest::hash_int hash;
42 typedef HashMapHdrTest::simple_item_counter item_counter;
43 typedef cc::opt::v::relaxed_ordering memory_model;
44 enum { dynamic_bucket_table = false };
46 struct ordered_list_traits: public cc::michael_list::traits
48 typedef HashMapHdrTest::cmp compare;
52 struct HP_less_traits: public cc::split_list::traits
54 typedef cc::michael_list_tag ordered_list;
55 typedef HashMapHdrTest::hash_int hash;
56 typedef HashMapHdrTest::simple_item_counter item_counter;
57 typedef cc::opt::v::sequential_consistent memory_model;
58 enum { dynamic_bucket_table = false };
60 struct ordered_list_traits: public cc::michael_list::traits
62 typedef HashMapHdrTest::less less;
66 struct HP_cmpmix_traits: public cc::split_list::traits
68 typedef cc::michael_list_tag ordered_list;
69 typedef HashMapHdrTest::hash_int hash;
70 typedef HashMapHdrTest::simple_item_counter item_counter;
72 struct ordered_list_traits: public cc::michael_list::traits
74 typedef HashMapHdrTest::cmp compare;
75 typedef std::less<HashMapHdrTest::key_type> less;
79 struct HP_cmpmix_stat_traits : public HP_cmpmix_traits
81 typedef cc::split_list::stat<> stat;
86 void HashMapHdrTest::Split_HP_cmp()
88 // traits-based version
89 typedef cc::SplitListMap< cds::gc::HP, key_type, value_type, HP_cmp_traits > map_type;
90 test_int< map_type >();
92 // option-based version
93 typedef cc::SplitListMap< cds::gc::HP,
96 cc::split_list::make_traits<
97 cc::split_list::ordered_list<cc::michael_list_tag>
98 ,cc::opt::hash< hash_int >
99 ,cc::opt::item_counter< simple_item_counter >
100 ,cc::opt::memory_model< cc::opt::v::relaxed_ordering >
101 ,cc::split_list::dynamic_bucket_table< true >
102 ,cc::split_list::ordered_list_traits<
103 cc::michael_list::make_traits<
104 cc::opt::compare< cmp >
109 test_int< opt_map >();
112 void HashMapHdrTest::Split_HP_less()
114 // traits-based version
115 typedef cc::SplitListMap< cds::gc::HP, key_type, value_type, HP_less_traits > map_type;
116 test_int< map_type >();
118 // option-based version
119 typedef cc::SplitListMap< cds::gc::HP,
122 cc::split_list::make_traits<
123 cc::split_list::ordered_list<cc::michael_list_tag>
124 ,cc::opt::hash< hash_int >
125 ,cc::opt::item_counter< simple_item_counter >
126 ,cc::opt::memory_model< cc::opt::v::relaxed_ordering >
127 ,cc::split_list::dynamic_bucket_table< true >
128 ,cc::split_list::ordered_list_traits<
129 cc::michael_list::make_traits<
130 cc::opt::less< less >
135 test_int< opt_map >();
138 void HashMapHdrTest::Split_HP_cmpmix()
140 // traits-based version
141 typedef cc::SplitListMap< cds::gc::HP, key_type, value_type, HP_cmpmix_traits > map_type;
142 test_int< map_type >();
144 // option-based version
145 typedef cc::SplitListMap< cds::gc::HP,
148 cc::split_list::make_traits<
149 cc::split_list::ordered_list<cc::michael_list_tag>
150 ,cc::opt::hash< hash_int >
151 ,cc::opt::item_counter< simple_item_counter >
152 ,cc::split_list::ordered_list_traits<
153 cc::michael_list::make_traits<
154 cc::opt::less< std::less<key_type> >
155 ,cc::opt::compare< cmp >
160 test_int< opt_map >();
163 void HashMapHdrTest::Split_HP_cmpmix_stat()
165 // traits-based version
166 typedef cc::SplitListMap< cds::gc::HP, key_type, value_type, HP_cmpmix_stat_traits > map_type;
167 test_int< map_type >();
169 // option-based version
170 typedef cc::SplitListMap< cds::gc::HP,
173 cc::split_list::make_traits<
174 cc::split_list::ordered_list<cc::michael_list_tag>
175 ,cc::opt::hash< hash_int >
176 ,cc::opt::item_counter< simple_item_counter >
177 ,cc::split_list::ordered_list_traits<
178 cc::michael_list::make_traits<
179 cc::opt::less< std::less<key_type> >
180 ,cc::opt::compare< cmp >
183 ,cds::opt::stat< cc::split_list::stat<>>
186 test_int< opt_map >();