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/lazy_kvlist_nogc.h>
33 #include <cds/container/michael_map_nogc.h>
37 struct map_traits: public cc::michael_map::traits
39 typedef HashMapHdrTest::hash_int hash;
40 typedef HashMapHdrTest::simple_item_counter item_counter;
42 struct nogc_cmp_traits: public cc::lazy_list::traits
44 typedef HashMapHdrTest::cmp compare;
47 struct nogc_less_traits: public cc::lazy_list::traits
49 typedef HashMapHdrTest::less less;
52 struct nogc_cmpmix_traits: public cc::lazy_list::traits
54 typedef HashMapHdrTest::cmp compare;
55 typedef HashMapHdrTest::less less;
58 struct nogc_equal_traits: public cc::lazy_list::traits
60 typedef HashMapHdrTest::equal equal_to;
61 static const bool sort = false;
65 void HashMapHdrTest::Lazy_nogc_cmp()
67 typedef cc::LazyKVList< cds::gc::nogc, int, HashMapHdrTest::value_type, nogc_cmp_traits > list;
69 // traits-based version
70 typedef cc::MichaelHashMap< cds::gc::nogc, list, map_traits > map;
71 test_int_nogc< map >();
73 // option-based version
74 typedef cc::MichaelHashMap< cds::gc::nogc, list,
75 cc::michael_map::make_traits<
76 cc::opt::hash< hash_int >
77 ,cc::opt::item_counter< simple_item_counter >
80 test_int_nogc< opt_map >();
83 void HashMapHdrTest::Lazy_nogc_less()
85 typedef cc::LazyKVList< cds::gc::nogc, int, HashMapHdrTest::value_type, nogc_less_traits > list;
87 // traits-based version
88 typedef cc::MichaelHashMap< cds::gc::nogc, list, map_traits > map;
89 test_int_nogc< map >();
91 // option-based version
92 typedef cc::MichaelHashMap< cds::gc::nogc, list,
93 cc::michael_map::make_traits<
94 cc::opt::hash< hash_int >
95 ,cc::opt::item_counter< simple_item_counter >
98 test_int_nogc< opt_map >();
101 void HashMapHdrTest::Lazy_nogc_equal()
103 typedef cc::LazyKVList< cds::gc::nogc, int, HashMapHdrTest::value_type, nogc_equal_traits > list;
105 // traits-based version
106 typedef cc::MichaelHashMap< cds::gc::nogc, list, map_traits > map;
107 test_int_nogc_unordered< map >();
109 // option-based version
110 typedef cc::MichaelHashMap< cds::gc::nogc, list,
111 cc::michael_map::make_traits<
112 cc::opt::hash< hash_int >
113 ,cc::opt::item_counter< simple_item_counter >
116 test_int_nogc_unordered< opt_map >();
119 void HashMapHdrTest::Lazy_nogc_cmpmix()
121 typedef cc::LazyKVList< cds::gc::nogc, int, HashMapHdrTest::value_type, nogc_cmpmix_traits > list;
123 // traits-based version
124 typedef cc::MichaelHashMap< cds::gc::nogc, list, map_traits > map;
125 test_int_nogc< map >();
127 // option-based version
128 typedef cc::MichaelHashMap< cds::gc::nogc, list,
129 cc::michael_map::make_traits<
130 cc::opt::hash< hash_int >
131 ,cc::opt::item_counter< simple_item_counter >
134 test_int_nogc< opt_map >();