Added copyright and license
[libcds.git] / tests / test-hdr / map / hdr_michael_map_lazy_nogc.cpp
1 /*
2     This file is a part of libcds - Concurrent Data Structures library
3
4     (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
5
6     Source code repo: http://github.com/khizmax/libcds/
7     Download: http://sourceforge.net/projects/libcds/files/
8     
9     Redistribution and use in source and binary forms, with or without
10     modification, are permitted provided that the following conditions are met:
11
12     * Redistributions of source code must retain the above copyright notice, this
13       list of conditions and the following disclaimer.
14
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.
18
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.     
29 */
30
31 #include "map/hdr_map.h"
32 #include <cds/container/lazy_kvlist_nogc.h>
33 #include <cds/container/michael_map_nogc.h>
34
35 namespace map {
36     namespace {
37         struct map_traits: public cc::michael_map::traits
38         {
39             typedef HashMapHdrTest::hash_int            hash;
40             typedef HashMapHdrTest::simple_item_counter item_counter;
41         };
42         struct nogc_cmp_traits: public cc::lazy_list::traits
43         {
44             typedef HashMapHdrTest::cmp   compare;
45         };
46
47         struct nogc_less_traits: public cc::lazy_list::traits
48         {
49             typedef HashMapHdrTest::less  less;
50         };
51
52         struct nogc_cmpmix_traits: public cc::lazy_list::traits
53         {
54             typedef HashMapHdrTest::cmp   compare;
55             typedef HashMapHdrTest::less  less;
56         };
57
58         struct nogc_equal_traits: public cc::lazy_list::traits
59         {
60             typedef HashMapHdrTest::equal  equal_to;
61             static const bool sort = false;
62         };
63     }
64
65     void HashMapHdrTest::Lazy_nogc_cmp()
66     {
67         typedef cc::LazyKVList< cds::gc::nogc, int, HashMapHdrTest::value_type, nogc_cmp_traits > list;
68
69         // traits-based version
70         typedef cc::MichaelHashMap< cds::gc::nogc, list, map_traits > map;
71         test_int_nogc< map >();
72
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 >
78             >::type
79         > opt_map;
80         test_int_nogc< opt_map >();
81     }
82
83     void HashMapHdrTest::Lazy_nogc_less()
84     {
85         typedef cc::LazyKVList< cds::gc::nogc, int, HashMapHdrTest::value_type, nogc_less_traits > list;
86
87         // traits-based version
88         typedef cc::MichaelHashMap< cds::gc::nogc, list, map_traits > map;
89         test_int_nogc< map >();
90
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 >
96             >::type
97         > opt_map;
98         test_int_nogc< opt_map >();
99     }
100
101     void HashMapHdrTest::Lazy_nogc_equal()
102     {
103         typedef cc::LazyKVList< cds::gc::nogc, int, HashMapHdrTest::value_type, nogc_equal_traits > list;
104
105         // traits-based version
106         typedef cc::MichaelHashMap< cds::gc::nogc, list, map_traits > map;
107         test_int_nogc_unordered< map >();
108
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 >
114             >::type
115         > opt_map;
116         test_int_nogc_unordered< opt_map >();
117     }
118
119     void HashMapHdrTest::Lazy_nogc_cmpmix()
120     {
121         typedef cc::LazyKVList< cds::gc::nogc, int, HashMapHdrTest::value_type, nogc_cmpmix_traits > list;
122
123         // traits-based version
124         typedef cc::MichaelHashMap< cds::gc::nogc, list, map_traits > map;
125         test_int_nogc< map >();
126
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 >
132             >::type
133         > opt_map;
134         test_int_nogc< opt_map >();
135     }
136
137 }   // namespace map