Formatting
[libcds.git] / tests / test-hdr / set / hdr_intrusive_striped_hashset_splayset.cpp
1 //$$CDS-header$$
2
3 #include "set/hdr_intrusive_striped_set.h"
4 #include <cds/intrusive/striped_set/boost_splay_set.h>
5 #include <cds/intrusive/striped_set.h>
6 #include <boost/version.hpp>
7
8 namespace set {
9     namespace bi = boost::intrusive;
10
11     namespace {
12 #   if BOOST_VERSION < 105600
13         typedef bi::splay_set_member_hook<> splay_set_member_hook;
14         typedef bi::splay_set_base_hook<> splay_set_base_hook;
15 #else
16         typedef bi::bs_set_base_hook<> splay_set_base_hook;
17         typedef bi::bs_set_member_hook<> splay_set_member_hook;
18 #endif
19
20         typedef IntrusiveStripedSetHdrTest::base_item< splay_set_base_hook> base_item_type;
21         typedef IntrusiveStripedSetHdrTest::member_item< splay_set_member_hook > member_item_type;
22
23         template <typename T, typename Node>
24         struct get_key
25         {
26             typedef T type;
27
28             type const& operator()( Node const& v ) const
29             {
30                 return v.nKey;
31             }
32         };
33     }
34
35 #if BOOST_VERSION >= 105900
36 #   define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) ,bi::key_of_value< get_key< int, type>>
37 #else
38 #   define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type )
39 #endif
40
41
42     void IntrusiveStripedSetHdrTest::Striped_splay_set_basehook()
43     {
44         typedef ci::StripedSet<
45             bi::splay_set<base_item_type
46                 , bi::compare<IntrusiveStripedSetHdrTest::less<base_item_type>>
47                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type )
48             >
49             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
50             ,co::mutex_policy< ci::striped_set::striping<> >
51         > set_type;
52
53         test<set_type>();
54     }
55
56     void IntrusiveStripedSetHdrTest::Striped_splay_set_basehook_bucket_threshold()
57     {
58         typedef ci::StripedSet<
59             bi::splay_set<base_item_type
60                 , bi::compare<IntrusiveStripedSetHdrTest::less<base_item_type>>
61                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type )
62             >
63             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
64             ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<64> >
65         > set_type;
66
67         test<set_type>();
68     }
69
70     void IntrusiveStripedSetHdrTest::Striped_splay_set_basehook_bucket_threshold_rt()
71     {
72         typedef ci::StripedSet<
73             bi::splay_set<base_item_type
74                 , bi::compare<IntrusiveStripedSetHdrTest::less<base_item_type>>
75                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type )
76             >
77             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
78             ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> >
79         > set_type;
80
81         set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>(256) );
82         test_with( s );
83     }
84
85     void IntrusiveStripedSetHdrTest::Striped_splay_set_memberhook()
86     {
87         typedef ci::StripedSet<
88             bi::splay_set<
89                 member_item_type
90                 , bi::member_hook< member_item_type, splay_set_member_hook, &member_item_type::hMember>
91                 , bi::compare<IntrusiveStripedSetHdrTest::less<member_item_type> >
92                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type )
93             >
94             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
95         > set_type;
96
97         test<set_type>();
98     }
99
100     void IntrusiveStripedSetHdrTest::Striped_splay_set_memberhook_bucket_threshold()
101     {
102         typedef ci::StripedSet<
103             bi::splay_set<
104                 member_item_type
105                 , bi::member_hook< member_item_type, splay_set_member_hook, &member_item_type::hMember>
106                 , bi::compare<IntrusiveStripedSetHdrTest::less<member_item_type>>
107                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type )
108             >
109             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
110             ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<256> >
111         > set_type;
112
113         test<set_type>();
114     }
115
116     void IntrusiveStripedSetHdrTest::Striped_splay_set_memberhook_bucket_threshold_rt()
117     {
118         typedef ci::StripedSet<
119             bi::splay_set<
120                 member_item_type
121                 , bi::member_hook< member_item_type, splay_set_member_hook, &member_item_type::hMember>
122                 , bi::compare<IntrusiveStripedSetHdrTest::less<member_item_type>>
123                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type )
124             >
125             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
126             ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> >
127         > set_type;
128
129         set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>(256) );
130         test_with( s );
131     }
132
133 } // namespace set
134
135