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