Split up set2 unit test to reduce compiling time and memory
[libcds.git] / cds / container / details / split_list_base.h
1 //$$CDS-header$$
2
3 #ifndef CDSLIB_CONTAINER_DETAILS_SPLIT_LIST_BASE_H
4 #define CDSLIB_CONTAINER_DETAILS_SPLIT_LIST_BASE_H
5
6 #include <cds/intrusive/details/split_list_base.h>
7
8 namespace cds { namespace container {
9
10     // forward declaration
11     struct michael_list_tag;
12
13     /// SplitListSet related definitions
14     /** @ingroup cds_nonintrusive_helper
15     */
16     namespace split_list {
17         using cds::intrusive::split_list::implementation_tag;
18
19         /// Internal statistics, see \p cds::intrusive::split_list::stat
20         template <typename Counter = cds::intrusive::split_list::stat<>::counter_type >
21         using stat = cds::intrusive::split_list::stat<Counter>;
22
23         /// Disabled internal statistics, see \p cds::intrusive::split_list::empty_stat
24         typedef cds::intrusive::split_list::empty_stat empty_stat;
25
26         /// Selector of bucket table implementation =- typedef for \p intrusive::split_list::dynamic_bucket_table
27         template <bool Value>
28         using dynamic_bucket_table = cds::intrusive::split_list::dynamic_bucket_table<Value>;
29
30         using cds::intrusive::split_list::static_bucket_table;
31         using cds::intrusive::split_list::expandable_bucket_table;
32
33         //@cond
34         namespace details {
35
36             template <typename Key, typename Value, typename Traits, typename Opt>
37             struct wrap_map_traits_helper {
38                 typedef Opt key_accessor;
39             };
40
41             template <typename Key, typename Value, typename Traits >
42             struct wrap_map_traits_helper<Key, Value, Traits, opt::none>
43             {
44                 struct key_accessor
45                 {
46                     typedef Key     key_type;
47                     key_type const & operator()( std::pair<Key const, Value> const & val ) const
48                     {
49                         return val.first;
50                     }
51                 };
52             };
53
54             template <typename Key, typename Value, typename Traits>
55             struct wrap_map_traits: public Traits
56             {
57                 typedef typename wrap_map_traits_helper<Key, Value, Traits, typename Traits::key_accessor>::key_accessor    key_accessor;
58             };
59
60             template <typename Value, typename Traits, typename Opt>
61             struct wrap_set_traits_helper {
62                 typedef Opt key_accessor;
63             };
64
65             template <typename Value, typename Traits >
66             struct wrap_set_traits_helper<Value, Traits, opt::none>
67             {
68                 struct key_accessor
69                 {
70                     typedef Value     key_type;
71                     key_type const& operator()( Value const& val ) const
72                     {
73                         return val;
74                     }
75                 };
76             };
77
78             template <typename Value, typename Traits>
79             struct wrap_set_traits: public Traits
80             {
81                 typedef typename wrap_set_traits_helper<Value, Traits, typename Traits::key_accessor>::key_accessor key_accessor;
82             };
83         }  // namespace details
84         //@endcond
85
86
87         /// SplitListSet traits
88         struct traits: public intrusive::split_list::traits
89         {
90             // Ordered list implementation
91             /**
92                 Selects appropriate ordered-list implementation for split-list.
93                 Supported types are:
94                 - \p michael_list_tag - for MichaelList
95                 - \p lazy_list_tag - for LazyList
96             */
97             typedef michael_list_tag    ordered_list;
98
99             // Ordered list traits
100             /**
101                 Specifyes traits for selected ordered list type, default type:
102                 - for \p michael_list_tag: \p container::michael_list::traits.
103                 - for \p lazy_list_tag: \p container::lazy_list::traits.
104
105                 If this type is \p opt::none, the ordered list traits is combined with default
106                 ordered list traits above and split-list traits.
107             */
108             typedef opt::none           ordered_list_traits;
109
110             //@cond
111             typedef opt::none           key_accessor;
112             //@endcond
113         };
114
115         /// Option to select ordered list class for split-list
116         /**
117             This option selects appropriate ordered list class for containers based on split-list.
118             Template parameter \p Type may be \p michael_list_tag or \p lazy_list_tag.
119         */
120         template <class Type>
121         struct ordered_list
122         {
123             //@cond
124             template<class Base> struct pack: public Base
125             {
126                 typedef Type ordered_list;
127             };
128             //@endcond
129         };
130
131         /// Option to specify ordered list type traits
132         /**
133             The \p Type template parameter specifies ordered list type traits.
134             It depends on type of ordered list selected.
135         */
136         template <class Type>
137         struct ordered_list_traits
138         {
139             //@cond
140             template<class Base> struct pack: public Base
141             {
142                 typedef Type ordered_list_traits;
143             };
144             //@endcond
145         };
146
147         /// Metafunction converting option list to traits struct
148         /**
149             Available \p Options:
150             - \p split_list::ordered_list - a tag for ordered list implementation.
151             - \p split_list::ordered_list_traits - type traits for ordered list implementation.
152                 For \p MichaelList use \p container::michael_list::traits or derivatives,
153                 for \p LazyList use \p container::lazy_list::traits or derivatives.
154             - plus any option from \p intrusive::split_list::make_traits
155         */
156         template <typename... Options>
157         struct make_traits {
158             typedef typename cds::opt::make_options< traits, Options...>::type type  ;   ///< Result of metafunction
159         };
160     }   // namespace split_list
161
162     //@cond
163     // Forward declarations
164     template <class GC, class T, class Traits = split_list::traits>
165     class SplitListSet;
166
167     template <class GC, typename Key, typename Value, class Traits = split_list::traits>
168     class SplitListMap;
169     //@endcond
170
171     //@cond
172     // Forward declaration
173     namespace details {
174         template <typename GC, typename T, typename OrderedListTag, typename Traits>
175         struct make_split_list_set;
176
177         template <typename GC, typename Key, typename Value, typename OrderedListTag, typename Traits>
178         struct make_split_list_map;
179     }
180     //@endcond
181
182 }}  // namespace cds::container
183
184
185 #endif // #ifndef CDSLIB_CONTAINER_DETAILS_SPLIT_LIST_BASE_H