Added copyright and license
[libcds.git] / tests / test-hdr / set / hdr_intrusive_michael_set_dhp_lazy.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 "set/hdr_intrusive_set.h"
32 #include <cds/intrusive/lazy_list_dhp.h>
33 #include <cds/intrusive/michael_set.h>
34
35 namespace set {
36
37     void IntrusiveHashSetHdrTest::DHP_base_cmp_lazy()
38     {
39         typedef base_int_item< ci::lazy_list::node<cds::gc::DHP> > item;
40         typedef ci::LazyList< cds::gc::DHP
41             ,item
42             ,ci::lazy_list::make_traits<
43                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<cds::gc::DHP> > >
44                 ,co::compare< cmp<item> >
45                 ,ci::opt::disposer< faked_disposer >
46             >::type
47         >    bucket_type;
48
49         typedef ci::MichaelHashSet< cds::gc::DHP, bucket_type,
50             ci::michael_set::make_traits<
51                 co::hash< hash_int >
52             >::type
53         > set;
54
55         test_int<set>();
56     }
57
58     void IntrusiveHashSetHdrTest::DHP_base_less_lazy()
59     {
60         typedef base_int_item< ci::lazy_list::node<cds::gc::DHP> > item;
61         typedef ci::LazyList< cds::gc::DHP
62             ,item
63             ,ci::lazy_list::make_traits<
64                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<cds::gc::DHP> > >
65                 ,co::less< less<item> >
66                 ,ci::opt::disposer< faked_disposer >
67             >::type
68         >    bucket_type;
69
70         typedef ci::MichaelHashSet< cds::gc::DHP, bucket_type,
71             ci::michael_set::make_traits<
72                 co::hash< hash_int >
73             >::type
74         > set;
75
76         test_int<set>();
77     }
78
79     void IntrusiveHashSetHdrTest::DHP_base_cmpmix_lazy()
80     {
81         typedef base_int_item< ci::lazy_list::node<cds::gc::DHP> > item;
82         typedef ci::LazyList< cds::gc::DHP
83             ,item
84             ,ci::lazy_list::make_traits<
85                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<cds::gc::DHP> > >
86                 ,co::less< less<item> >
87                 ,co::compare< cmp<item> >
88                 ,ci::opt::disposer< faked_disposer >
89             >::type
90         >    bucket_type;
91
92         typedef ci::MichaelHashSet< cds::gc::DHP, bucket_type,
93             ci::michael_set::make_traits<
94                 co::hash< hash_int >
95                 ,co::item_counter< simple_item_counter >
96             >::type
97         > set;
98
99         test_int<set>();
100     }
101
102     void IntrusiveHashSetHdrTest::DHP_member_cmp_lazy()
103     {
104         typedef member_int_item< ci::lazy_list::node<cds::gc::DHP> > item;
105         typedef ci::LazyList< cds::gc::DHP
106             ,item
107             ,ci::lazy_list::make_traits<
108                 ci::opt::hook< ci::lazy_list::member_hook<
109                     offsetof( item, hMember ),
110                     co::gc<cds::gc::DHP>
111                 > >
112                 ,co::compare< cmp<item> >
113                 ,ci::opt::disposer< faked_disposer >
114             >::type
115         >    bucket_type;
116
117         typedef ci::MichaelHashSet< cds::gc::DHP, bucket_type,
118             ci::michael_set::make_traits<
119                 co::hash< hash_int >
120             >::type
121         > set;
122
123         test_int<set>();
124     }
125
126     void IntrusiveHashSetHdrTest::DHP_member_less_lazy()
127     {
128         typedef member_int_item< ci::lazy_list::node<cds::gc::DHP> > item;
129         typedef ci::LazyList< cds::gc::DHP
130             ,item
131             ,ci::lazy_list::make_traits<
132                 ci::opt::hook< ci::lazy_list::member_hook<
133                     offsetof( item, hMember ),
134                     co::gc<cds::gc::DHP>
135                 > >
136                 ,co::less< less<item> >
137                 ,ci::opt::disposer< faked_disposer >
138             >::type
139         >    bucket_type;
140
141         typedef ci::MichaelHashSet< cds::gc::DHP, bucket_type,
142             ci::michael_set::make_traits<
143                 co::hash< hash_int >
144             >::type
145         > set;
146
147         test_int<set>();
148     }
149
150     void IntrusiveHashSetHdrTest::DHP_member_cmpmix_lazy()
151     {
152         typedef member_int_item< ci::lazy_list::node<cds::gc::DHP> > item;
153         typedef ci::LazyList< cds::gc::DHP
154             ,item
155             ,ci::lazy_list::make_traits<
156                 ci::opt::hook< ci::lazy_list::member_hook<
157                     offsetof( item, hMember ),
158                     co::gc<cds::gc::DHP>
159                 > >
160                 ,co::compare< cmp<item> >
161                 ,co::less< less<item> >
162                 ,ci::opt::disposer< faked_disposer >
163             >::type
164         >    bucket_type;
165
166         typedef ci::MichaelHashSet< cds::gc::DHP, bucket_type,
167             ci::michael_set::make_traits<
168                 co::hash< hash_int >
169                 ,co::item_counter< simple_item_counter >
170             >::type
171         > set;
172
173         test_int<set>();
174     }
175
176
177 } // namespace set