Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/intrusive/bs_set.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 ///////////////////////////////////////////////////////////////////////////// | |
2 // | |
3 // (C) Copyright Ion Gaztanaga 2013-2013 | |
4 // | |
5 // Distributed under the Boost Software License, Version 1.0. | |
6 // (See accompanying file LICENSE_1_0.txt or copy at | |
7 // http://www.boost.org/LICENSE_1_0.txt) | |
8 // | |
9 // See http://www.boost.org/libs/intrusive for documentation. | |
10 // | |
11 ///////////////////////////////////////////////////////////////////////////// | |
12 #ifndef BOOST_INTRUSIVE_BS_SET_HPP | |
13 #define BOOST_INTRUSIVE_BS_SET_HPP | |
14 | |
15 #include <boost/intrusive/detail/config_begin.hpp> | |
16 #include <boost/intrusive/intrusive_fwd.hpp> | |
17 #include <boost/intrusive/detail/mpl.hpp> | |
18 #include <boost/intrusive/bstree.hpp> | |
19 #include <iterator> | |
20 #include <boost/move/move.hpp> | |
21 | |
22 namespace boost { | |
23 namespace intrusive { | |
24 | |
25 //! The class template bs_set is an intrusive container, that mimics most of | |
26 //! the interface of std::set as described in the C++ standard. | |
27 //! | |
28 //! The template parameter \c T is the type to be managed by the container. | |
29 //! The user can specify additional options and if no options are provided | |
30 //! default options are used. | |
31 //! | |
32 //! The container supports the following options: | |
33 //! \c base_hook<>/member_hook<>/value_traits<>, | |
34 //! \c constant_time_size<>, \c size_type<> and | |
35 //! \c compare<>. | |
36 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
37 template<class T, class ...Options> | |
38 #else | |
39 template<class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize> | |
40 #endif | |
41 class bs_set_impl | |
42 #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED | |
43 : public bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, BsTreeAlgorithms> | |
44 #endif | |
45 { | |
46 /// @cond | |
47 typedef bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, BsTreeAlgorithms> tree_type; | |
48 BOOST_MOVABLE_BUT_NOT_COPYABLE(bs_set_impl) | |
49 | |
50 typedef tree_type implementation_defined; | |
51 /// @endcond | |
52 | |
53 public: | |
54 typedef typename implementation_defined::value_type value_type; | |
55 typedef typename implementation_defined::value_traits value_traits; | |
56 typedef typename implementation_defined::pointer pointer; | |
57 typedef typename implementation_defined::const_pointer const_pointer; | |
58 typedef typename implementation_defined::reference reference; | |
59 typedef typename implementation_defined::const_reference const_reference; | |
60 typedef typename implementation_defined::difference_type difference_type; | |
61 typedef typename implementation_defined::size_type size_type; | |
62 typedef typename implementation_defined::value_compare value_compare; | |
63 typedef typename implementation_defined::key_compare key_compare; | |
64 typedef typename implementation_defined::iterator iterator; | |
65 typedef typename implementation_defined::const_iterator const_iterator; | |
66 typedef typename implementation_defined::reverse_iterator reverse_iterator; | |
67 typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator; | |
68 typedef typename implementation_defined::insert_commit_data insert_commit_data; | |
69 typedef typename implementation_defined::node_traits node_traits; | |
70 typedef typename implementation_defined::node node; | |
71 typedef typename implementation_defined::node_ptr node_ptr; | |
72 typedef typename implementation_defined::const_node_ptr const_node_ptr; | |
73 typedef typename implementation_defined::node_algorithms node_algorithms; | |
74 | |
75 static const bool constant_time_size = tree_type::constant_time_size; | |
76 | |
77 public: | |
78 //! @copydoc ::boost::intrusive::bstree::bstree(const value_compare &,const value_traits &) | |
79 explicit bs_set_impl( const value_compare &cmp = value_compare() | |
80 , const value_traits &v_traits = value_traits()) | |
81 : tree_type(cmp, v_traits) | |
82 {} | |
83 | |
84 //! @copydoc ::boost::intrusive::bstree::bstree(bool,Iterator,Iterator,const value_compare &,const value_traits &) | |
85 template<class Iterator> | |
86 bs_set_impl( Iterator b, Iterator e | |
87 , const value_compare &cmp = value_compare() | |
88 , const value_traits &v_traits = value_traits()) | |
89 : tree_type(true, b, e, cmp, v_traits) | |
90 {} | |
91 | |
92 //! @copydoc ::boost::intrusive::bstree::bstree(bstree &&) | |
93 bs_set_impl(BOOST_RV_REF(bs_set_impl) x) | |
94 : tree_type(::boost::move(static_cast<tree_type&>(x))) | |
95 {} | |
96 | |
97 //! @copydoc ::boost::intrusive::bstree::operator=(bstree &&) | |
98 bs_set_impl& operator=(BOOST_RV_REF(bs_set_impl) x) | |
99 { return static_cast<bs_set_impl&>(tree_type::operator=(::boost::move(static_cast<tree_type&>(x)))); } | |
100 | |
101 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED | |
102 //! @copydoc ::boost::intrusive::bstree::~bstree() | |
103 ~bs_set_impl(); | |
104 | |
105 //! @copydoc ::boost::intrusive::bstree::begin() | |
106 iterator begin(); | |
107 | |
108 //! @copydoc ::boost::intrusive::bstree::begin()const | |
109 const_iterator begin() const; | |
110 | |
111 //! @copydoc ::boost::intrusive::bstree::cbegin()const | |
112 const_iterator cbegin() const; | |
113 | |
114 //! @copydoc ::boost::intrusive::bstree::end() | |
115 iterator end(); | |
116 | |
117 //! @copydoc ::boost::intrusive::bstree::end()const | |
118 const_iterator end() const; | |
119 | |
120 //! @copydoc ::boost::intrusive::bstree::cend()const | |
121 const_iterator cend() const; | |
122 | |
123 //! @copydoc ::boost::intrusive::bstree::rbegin() | |
124 reverse_iterator rbegin(); | |
125 | |
126 //! @copydoc ::boost::intrusive::bstree::rbegin()const | |
127 const_reverse_iterator rbegin() const; | |
128 | |
129 //! @copydoc ::boost::intrusive::bstree::crbegin()const | |
130 const_reverse_iterator crbegin() const; | |
131 | |
132 //! @copydoc ::boost::intrusive::bstree::rend() | |
133 reverse_iterator rend(); | |
134 | |
135 //! @copydoc ::boost::intrusive::bstree::rend()const | |
136 const_reverse_iterator rend() const; | |
137 | |
138 //! @copydoc ::boost::intrusive::bstree::crend()const | |
139 const_reverse_iterator crend() const; | |
140 | |
141 //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(iterator) | |
142 static bs_set_impl &container_from_end_iterator(iterator end_iterator); | |
143 | |
144 //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(const_iterator) | |
145 static const bs_set_impl &container_from_end_iterator(const_iterator end_iterator); | |
146 | |
147 //! @copydoc ::boost::intrusive::bstree::container_from_iterator(iterator) | |
148 static bs_set_impl &container_from_iterator(iterator it); | |
149 | |
150 //! @copydoc ::boost::intrusive::bstree::container_from_iterator(const_iterator) | |
151 static const bs_set_impl &container_from_iterator(const_iterator it); | |
152 | |
153 //! @copydoc ::boost::intrusive::bstree::key_comp()const | |
154 key_compare key_comp() const; | |
155 | |
156 //! @copydoc ::boost::intrusive::bstree::value_comp()const | |
157 value_compare value_comp() const; | |
158 | |
159 //! @copydoc ::boost::intrusive::bstree::empty()const | |
160 bool empty() const; | |
161 | |
162 //! @copydoc ::boost::intrusive::bstree::size()const | |
163 size_type size() const; | |
164 | |
165 //! @copydoc ::boost::intrusive::bstree::swap | |
166 void swap(bs_set_impl& other); | |
167 | |
168 //! @copydoc ::boost::intrusive::bstree::clone_from | |
169 template <class Cloner, class Disposer> | |
170 void clone_from(const bs_set_impl &src, Cloner cloner, Disposer disposer); | |
171 | |
172 #endif //#ifdef BOOST_iNTRUSIVE_DOXYGEN_INVOKED | |
173 | |
174 //! @copydoc ::boost::intrusive::bstree::insert_unique(reference) | |
175 std::pair<iterator, bool> insert(reference value) | |
176 { return tree_type::insert_unique(value); } | |
177 | |
178 //! @copydoc ::boost::intrusive::bstree::insert_unique(const_iterator,reference) | |
179 iterator insert(const_iterator hint, reference value) | |
180 { return tree_type::insert_unique(hint, value); } | |
181 | |
182 //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const KeyType&,KeyValueCompare,insert_commit_data&) | |
183 template<class KeyType, class KeyValueCompare> | |
184 std::pair<iterator, bool> insert_check | |
185 (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data) | |
186 { return tree_type::insert_unique_check(key, key_value_comp, commit_data); } | |
187 | |
188 //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const_iterator,const KeyType&,KeyValueCompare,insert_commit_data&) | |
189 template<class KeyType, class KeyValueCompare> | |
190 std::pair<iterator, bool> insert_check | |
191 (const_iterator hint, const KeyType &key | |
192 ,KeyValueCompare key_value_comp, insert_commit_data &commit_data) | |
193 { return tree_type::insert_unique_check(hint, key, key_value_comp, commit_data); } | |
194 | |
195 //! @copydoc ::boost::intrusive::bstree::insert_unique(Iterator,Iterator) | |
196 template<class Iterator> | |
197 void insert(Iterator b, Iterator e) | |
198 { tree_type::insert_unique(b, e); } | |
199 | |
200 //! @copydoc ::boost::intrusive::bstree::insert_unique_commit | |
201 iterator insert_commit(reference value, const insert_commit_data &commit_data) | |
202 { return tree_type::insert_unique_commit(value, commit_data); } | |
203 | |
204 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED | |
205 //! @copydoc ::boost::intrusive::bstree::insert_before | |
206 iterator insert_before(const_iterator pos, reference value); | |
207 | |
208 //! @copydoc ::boost::intrusive::bstree::push_back | |
209 void push_back(reference value); | |
210 | |
211 //! @copydoc ::boost::intrusive::bstree::push_front | |
212 void push_front(reference value); | |
213 | |
214 //! @copydoc ::boost::intrusive::bstree::erase(const_iterator) | |
215 iterator erase(const_iterator i); | |
216 | |
217 //! @copydoc ::boost::intrusive::bstree::erase(const_iterator,const_iterator) | |
218 iterator erase(const_iterator b, const_iterator e); | |
219 | |
220 //! @copydoc ::boost::intrusive::bstree::erase(const_reference) | |
221 size_type erase(const_reference value); | |
222 | |
223 //! @copydoc ::boost::intrusive::bstree::erase(const KeyType&,KeyValueCompare) | |
224 template<class KeyType, class KeyValueCompare> | |
225 size_type erase(const KeyType& key, KeyValueCompare comp); | |
226 | |
227 //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,Disposer) | |
228 template<class Disposer> | |
229 iterator erase_and_dispose(const_iterator i, Disposer disposer); | |
230 | |
231 //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,const_iterator,Disposer) | |
232 template<class Disposer> | |
233 iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer); | |
234 | |
235 //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_reference, Disposer) | |
236 template<class Disposer> | |
237 size_type erase_and_dispose(const_reference value, Disposer disposer); | |
238 | |
239 //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const KeyType&,KeyValueCompare,Disposer) | |
240 template<class KeyType, class KeyValueCompare, class Disposer> | |
241 size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer); | |
242 | |
243 //! @copydoc ::boost::intrusive::bstree::clear | |
244 void clear(); | |
245 | |
246 //! @copydoc ::boost::intrusive::bstree::clear_and_dispose | |
247 template<class Disposer> | |
248 void clear_and_dispose(Disposer disposer); | |
249 | |
250 //! @copydoc ::boost::intrusive::bstree::count(const_reference)const | |
251 size_type count(const_reference value) const; | |
252 | |
253 //! @copydoc ::boost::intrusive::bstree::count(const KeyType&,KeyValueCompare)const | |
254 template<class KeyType, class KeyValueCompare> | |
255 size_type count(const KeyType& key, KeyValueCompare comp) const; | |
256 | |
257 //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference) | |
258 iterator lower_bound(const_reference value); | |
259 | |
260 //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare) | |
261 template<class KeyType, class KeyValueCompare> | |
262 iterator lower_bound(const KeyType& key, KeyValueCompare comp); | |
263 | |
264 //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference)const | |
265 const_iterator lower_bound(const_reference value) const; | |
266 | |
267 //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare)const | |
268 template<class KeyType, class KeyValueCompare> | |
269 const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const; | |
270 | |
271 //! @copydoc ::boost::intrusive::bstree::upper_bound(const_reference) | |
272 iterator upper_bound(const_reference value); | |
273 | |
274 //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyValueCompare) | |
275 template<class KeyType, class KeyValueCompare> | |
276 iterator upper_bound(const KeyType& key, KeyValueCompare comp); | |
277 | |
278 //! @copydoc ::boost::intrusive::bstree::upper_bound(const_reference)const | |
279 const_iterator upper_bound(const_reference value) const; | |
280 | |
281 //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyValueCompare)const | |
282 template<class KeyType, class KeyValueCompare> | |
283 const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const; | |
284 | |
285 //! @copydoc ::boost::intrusive::bstree::find(const_reference) | |
286 iterator find(const_reference value); | |
287 | |
288 //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyValueCompare) | |
289 template<class KeyType, class KeyValueCompare> | |
290 iterator find(const KeyType& key, KeyValueCompare comp); | |
291 | |
292 //! @copydoc ::boost::intrusive::bstree::find(const_reference)const | |
293 const_iterator find(const_reference value) const; | |
294 | |
295 //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyValueCompare)const | |
296 template<class KeyType, class KeyValueCompare> | |
297 const_iterator find(const KeyType& key, KeyValueCompare comp) const; | |
298 | |
299 //! @copydoc ::boost::intrusive::bstree::equal_range(const_reference) | |
300 std::pair<iterator,iterator> equal_range(const_reference value); | |
301 | |
302 //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyValueCompare) | |
303 template<class KeyType, class KeyValueCompare> | |
304 std::pair<iterator,iterator> equal_range(const KeyType& key, KeyValueCompare comp); | |
305 | |
306 //! @copydoc ::boost::intrusive::bstree::equal_range(const_reference)const | |
307 std::pair<const_iterator, const_iterator> | |
308 equal_range(const_reference value) const; | |
309 | |
310 //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyValueCompare)const | |
311 template<class KeyType, class KeyValueCompare> | |
312 std::pair<const_iterator, const_iterator> | |
313 equal_range(const KeyType& key, KeyValueCompare comp) const; | |
314 | |
315 //! @copydoc ::boost::intrusive::bstree::bounded_range(const_reference,const_reference,bool,bool) | |
316 std::pair<iterator,iterator> bounded_range | |
317 (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed); | |
318 | |
319 //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool) | |
320 template<class KeyType, class KeyValueCompare> | |
321 std::pair<iterator,iterator> bounded_range | |
322 (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed); | |
323 | |
324 //! @copydoc ::boost::intrusive::bstree::bounded_range(const_reference,const_reference,bool,bool)const | |
325 std::pair<const_iterator, const_iterator> | |
326 bounded_range(const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) const; | |
327 | |
328 //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool)const | |
329 template<class KeyType, class KeyValueCompare> | |
330 std::pair<const_iterator, const_iterator> bounded_range | |
331 (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) const; | |
332 | |
333 //! @copydoc ::boost::intrusive::bstree::s_iterator_to(reference) | |
334 static iterator s_iterator_to(reference value); | |
335 | |
336 //! @copydoc ::boost::intrusive::bstree::s_iterator_to(const_reference) | |
337 static const_iterator s_iterator_to(const_reference value); | |
338 | |
339 //! @copydoc ::boost::intrusive::bstree::iterator_to(reference) | |
340 iterator iterator_to(reference value); | |
341 | |
342 //! @copydoc ::boost::intrusive::bstree::iterator_to(const_reference)const | |
343 const_iterator iterator_to(const_reference value) const; | |
344 | |
345 //! @copydoc ::boost::intrusive::bstree::init_node(reference) | |
346 static void init_node(reference value); | |
347 | |
348 //! @copydoc ::boost::intrusive::bstree::unlink_leftmost_without_rebalance | |
349 pointer unlink_leftmost_without_rebalance(); | |
350 | |
351 //! @copydoc ::boost::intrusive::bstree::replace_node | |
352 void replace_node(iterator replace_this, reference with_this); | |
353 | |
354 //! @copydoc ::boost::intrusive::bstree::remove_node | |
355 void remove_node(reference value); | |
356 #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED | |
357 }; | |
358 | |
359 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
360 | |
361 template<class T, class ...Options> | |
362 bool operator!= (const bs_set_impl<T, Options...> &x, const bs_set_impl<T, Options...> &y); | |
363 | |
364 template<class T, class ...Options> | |
365 bool operator>(const bs_set_impl<T, Options...> &x, const bs_set_impl<T, Options...> &y); | |
366 | |
367 template<class T, class ...Options> | |
368 bool operator<=(const bs_set_impl<T, Options...> &x, const bs_set_impl<T, Options...> &y); | |
369 | |
370 template<class T, class ...Options> | |
371 bool operator>=(const bs_set_impl<T, Options...> &x, const bs_set_impl<T, Options...> &y); | |
372 | |
373 template<class T, class ...Options> | |
374 void swap(bs_set_impl<T, Options...> &x, bs_set_impl<T, Options...> &y); | |
375 | |
376 #endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
377 | |
378 //! Helper metafunction to define a \c bs_set that yields to the same type when the | |
379 //! same options (either explicitly or implicitly) are used. | |
380 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | |
381 template<class T, class ...Options> | |
382 #else | |
383 template<class T, class O1 = void, class O2 = void | |
384 , class O3 = void, class O4 = void> | |
385 #endif | |
386 struct make_bs_set | |
387 { | |
388 /// @cond | |
389 typedef typename pack_options | |
390 < bstree_defaults, | |
391 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | |
392 O1, O2, O3, O4 | |
393 #else | |
394 Options... | |
395 #endif | |
396 >::type packed_options; | |
397 | |
398 typedef typename detail::get_value_traits | |
399 <T, typename packed_options::proto_value_traits>::type value_traits; | |
400 | |
401 typedef bs_set_impl | |
402 < value_traits | |
403 , typename packed_options::compare | |
404 , typename packed_options::size_type | |
405 , packed_options::constant_time_size | |
406 > implementation_defined; | |
407 /// @endcond | |
408 typedef implementation_defined type; | |
409 }; | |
410 | |
411 #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED | |
412 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | |
413 template<class T, class O1, class O2, class O3, class O4> | |
414 #else | |
415 template<class T, class ...Options> | |
416 #endif | |
417 class bs_set | |
418 : public make_bs_set<T, | |
419 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | |
420 O1, O2, O3, O4 | |
421 #else | |
422 Options... | |
423 #endif | |
424 >::type | |
425 { | |
426 typedef typename make_bs_set | |
427 <T, | |
428 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | |
429 O1, O2, O3, O4 | |
430 #else | |
431 Options... | |
432 #endif | |
433 >::type Base; | |
434 | |
435 BOOST_MOVABLE_BUT_NOT_COPYABLE(bs_set) | |
436 public: | |
437 typedef typename Base::value_compare value_compare; | |
438 typedef typename Base::value_traits value_traits; | |
439 typedef typename Base::iterator iterator; | |
440 typedef typename Base::const_iterator const_iterator; | |
441 | |
442 //Assert if passed value traits are compatible with the type | |
443 BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value)); | |
444 | |
445 explicit bs_set( const value_compare &cmp = value_compare() | |
446 , const value_traits &v_traits = value_traits()) | |
447 : Base(cmp, v_traits) | |
448 {} | |
449 | |
450 template<class Iterator> | |
451 bs_set( Iterator b, Iterator e | |
452 , const value_compare &cmp = value_compare() | |
453 , const value_traits &v_traits = value_traits()) | |
454 : Base(b, e, cmp, v_traits) | |
455 {} | |
456 | |
457 bs_set(BOOST_RV_REF(bs_set) x) | |
458 : Base(::boost::move(static_cast<Base&>(x))) | |
459 {} | |
460 | |
461 bs_set& operator=(BOOST_RV_REF(bs_set) x) | |
462 { return static_cast<bs_set &>(this->Base::operator=(::boost::move(static_cast<Base&>(x)))); } | |
463 | |
464 static bs_set &container_from_end_iterator(iterator end_iterator) | |
465 { return static_cast<bs_set &>(Base::container_from_end_iterator(end_iterator)); } | |
466 | |
467 static const bs_set &container_from_end_iterator(const_iterator end_iterator) | |
468 { return static_cast<const bs_set &>(Base::container_from_end_iterator(end_iterator)); } | |
469 | |
470 static bs_set &container_from_iterator(iterator it) | |
471 { return static_cast<bs_set &>(Base::container_from_iterator(it)); } | |
472 | |
473 static const bs_set &container_from_iterator(const_iterator it) | |
474 { return static_cast<const bs_set &>(Base::container_from_iterator(it)); } | |
475 }; | |
476 | |
477 #endif | |
478 | |
479 //! The class template bs_multiset is an intrusive container, that mimics most of | |
480 //! the interface of std::multiset as described in the C++ standard. | |
481 //! | |
482 //! The template parameter \c T is the type to be managed by the container. | |
483 //! The user can specify additional options and if no options are provided | |
484 //! default options are used. | |
485 //! | |
486 //! The container supports the following options: | |
487 //! \c base_hook<>/member_hook<>/value_traits<>, | |
488 //! \c constant_time_size<>, \c size_type<> and | |
489 //! \c compare<>. | |
490 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
491 template<class T, class ...Options> | |
492 #else | |
493 template<class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize> | |
494 #endif | |
495 class bs_multiset_impl | |
496 #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED | |
497 : public bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, RbTreeAlgorithms> | |
498 #endif | |
499 { | |
500 /// @cond | |
501 typedef bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, RbTreeAlgorithms> tree_type; | |
502 | |
503 BOOST_MOVABLE_BUT_NOT_COPYABLE(bs_multiset_impl) | |
504 typedef tree_type implementation_defined; | |
505 /// @endcond | |
506 | |
507 public: | |
508 typedef typename implementation_defined::value_type value_type; | |
509 typedef typename implementation_defined::value_traits value_traits; | |
510 typedef typename implementation_defined::pointer pointer; | |
511 typedef typename implementation_defined::const_pointer const_pointer; | |
512 typedef typename implementation_defined::reference reference; | |
513 typedef typename implementation_defined::const_reference const_reference; | |
514 typedef typename implementation_defined::difference_type difference_type; | |
515 typedef typename implementation_defined::size_type size_type; | |
516 typedef typename implementation_defined::value_compare value_compare; | |
517 typedef typename implementation_defined::key_compare key_compare; | |
518 typedef typename implementation_defined::iterator iterator; | |
519 typedef typename implementation_defined::const_iterator const_iterator; | |
520 typedef typename implementation_defined::reverse_iterator reverse_iterator; | |
521 typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator; | |
522 typedef typename implementation_defined::insert_commit_data insert_commit_data; | |
523 typedef typename implementation_defined::node_traits node_traits; | |
524 typedef typename implementation_defined::node node; | |
525 typedef typename implementation_defined::node_ptr node_ptr; | |
526 typedef typename implementation_defined::const_node_ptr const_node_ptr; | |
527 typedef typename implementation_defined::node_algorithms node_algorithms; | |
528 | |
529 static const bool constant_time_size = tree_type::constant_time_size; | |
530 | |
531 public: | |
532 //! @copydoc ::boost::intrusive::bstree::bstree(const value_compare &,const value_traits &) | |
533 explicit bs_multiset_impl( const value_compare &cmp = value_compare() | |
534 , const value_traits &v_traits = value_traits()) | |
535 : tree_type(cmp, v_traits) | |
536 {} | |
537 | |
538 //! @copydoc ::boost::intrusive::bstree::bstree(bool,Iterator,Iterator,const value_compare &,const value_traits &) | |
539 template<class Iterator> | |
540 bs_multiset_impl( Iterator b, Iterator e | |
541 , const value_compare &cmp = value_compare() | |
542 , const value_traits &v_traits = value_traits()) | |
543 : tree_type(false, b, e, cmp, v_traits) | |
544 {} | |
545 | |
546 //! @copydoc ::boost::intrusive::bstree::bstree(bstree &&) | |
547 bs_multiset_impl(BOOST_RV_REF(bs_multiset_impl) x) | |
548 : tree_type(::boost::move(static_cast<tree_type&>(x))) | |
549 {} | |
550 | |
551 //! @copydoc ::boost::intrusive::bstree::operator=(bstree &&) | |
552 bs_multiset_impl& operator=(BOOST_RV_REF(bs_multiset_impl) x) | |
553 { return static_cast<bs_multiset_impl&>(tree_type::operator=(::boost::move(static_cast<tree_type&>(x)))); } | |
554 | |
555 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED | |
556 //! @copydoc ::boost::intrusive::bstree::~bstree() | |
557 ~bs_multiset_impl(); | |
558 | |
559 //! @copydoc ::boost::intrusive::bstree::begin() | |
560 iterator begin(); | |
561 | |
562 //! @copydoc ::boost::intrusive::bstree::begin()const | |
563 const_iterator begin() const; | |
564 | |
565 //! @copydoc ::boost::intrusive::bstree::cbegin()const | |
566 const_iterator cbegin() const; | |
567 | |
568 //! @copydoc ::boost::intrusive::bstree::end() | |
569 iterator end(); | |
570 | |
571 //! @copydoc ::boost::intrusive::bstree::end()const | |
572 const_iterator end() const; | |
573 | |
574 //! @copydoc ::boost::intrusive::bstree::cend()const | |
575 const_iterator cend() const; | |
576 | |
577 //! @copydoc ::boost::intrusive::bstree::rbegin() | |
578 reverse_iterator rbegin(); | |
579 | |
580 //! @copydoc ::boost::intrusive::bstree::rbegin()const | |
581 const_reverse_iterator rbegin() const; | |
582 | |
583 //! @copydoc ::boost::intrusive::bstree::crbegin()const | |
584 const_reverse_iterator crbegin() const; | |
585 | |
586 //! @copydoc ::boost::intrusive::bstree::rend() | |
587 reverse_iterator rend(); | |
588 | |
589 //! @copydoc ::boost::intrusive::bstree::rend()const | |
590 const_reverse_iterator rend() const; | |
591 | |
592 //! @copydoc ::boost::intrusive::bstree::crend()const | |
593 const_reverse_iterator crend() const; | |
594 | |
595 //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(iterator) | |
596 static bs_multiset_impl &container_from_end_iterator(iterator end_iterator); | |
597 | |
598 //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(const_iterator) | |
599 static const bs_multiset_impl &container_from_end_iterator(const_iterator end_iterator); | |
600 | |
601 //! @copydoc ::boost::intrusive::bstree::container_from_iterator(iterator) | |
602 static bs_multiset_impl &container_from_iterator(iterator it); | |
603 | |
604 //! @copydoc ::boost::intrusive::bstree::container_from_iterator(const_iterator) | |
605 static const bs_multiset_impl &container_from_iterator(const_iterator it); | |
606 | |
607 //! @copydoc ::boost::intrusive::bstree::key_comp()const | |
608 key_compare key_comp() const; | |
609 | |
610 //! @copydoc ::boost::intrusive::bstree::value_comp()const | |
611 value_compare value_comp() const; | |
612 | |
613 //! @copydoc ::boost::intrusive::bstree::empty()const | |
614 bool empty() const; | |
615 | |
616 //! @copydoc ::boost::intrusive::bstree::size()const | |
617 size_type size() const; | |
618 | |
619 //! @copydoc ::boost::intrusive::bstree::swap | |
620 void swap(bs_multiset_impl& other); | |
621 | |
622 //! @copydoc ::boost::intrusive::bstree::clone_from | |
623 template <class Cloner, class Disposer> | |
624 void clone_from(const bs_multiset_impl &src, Cloner cloner, Disposer disposer); | |
625 | |
626 #endif //#ifdef BOOST_iNTRUSIVE_DOXYGEN_INVOKED | |
627 | |
628 //! @copydoc ::boost::intrusive::bstree::insert_equal(reference) | |
629 iterator insert(reference value) | |
630 { return tree_type::insert_equal(value); } | |
631 | |
632 //! @copydoc ::boost::intrusive::bstree::insert_equal(const_iterator,reference) | |
633 iterator insert(const_iterator hint, reference value) | |
634 { return tree_type::insert_equal(hint, value); } | |
635 | |
636 //! @copydoc ::boost::intrusive::bstree::insert_equal(Iterator,Iterator) | |
637 template<class Iterator> | |
638 void insert(Iterator b, Iterator e) | |
639 { tree_type::insert_equal(b, e); } | |
640 | |
641 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED | |
642 //! @copydoc ::boost::intrusive::bstree::insert_before | |
643 iterator insert_before(const_iterator pos, reference value); | |
644 | |
645 //! @copydoc ::boost::intrusive::bstree::push_back | |
646 void push_back(reference value); | |
647 | |
648 //! @copydoc ::boost::intrusive::bstree::push_front | |
649 void push_front(reference value); | |
650 | |
651 //! @copydoc ::boost::intrusive::bstree::erase(const_iterator) | |
652 iterator erase(const_iterator i); | |
653 | |
654 //! @copydoc ::boost::intrusive::bstree::erase(const_iterator,const_iterator) | |
655 iterator erase(const_iterator b, const_iterator e); | |
656 | |
657 //! @copydoc ::boost::intrusive::bstree::erase(const_reference) | |
658 size_type erase(const_reference value); | |
659 | |
660 //! @copydoc ::boost::intrusive::bstree::erase(const KeyType&,KeyValueCompare) | |
661 template<class KeyType, class KeyValueCompare> | |
662 size_type erase(const KeyType& key, KeyValueCompare comp); | |
663 | |
664 //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,Disposer) | |
665 template<class Disposer> | |
666 iterator erase_and_dispose(const_iterator i, Disposer disposer); | |
667 | |
668 //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,const_iterator,Disposer) | |
669 template<class Disposer> | |
670 iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer); | |
671 | |
672 //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_reference, Disposer) | |
673 template<class Disposer> | |
674 size_type erase_and_dispose(const_reference value, Disposer disposer); | |
675 | |
676 //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const KeyType&,KeyValueCompare,Disposer) | |
677 template<class KeyType, class KeyValueCompare, class Disposer> | |
678 size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer); | |
679 | |
680 //! @copydoc ::boost::intrusive::bstree::clear | |
681 void clear(); | |
682 | |
683 //! @copydoc ::boost::intrusive::bstree::clear_and_dispose | |
684 template<class Disposer> | |
685 void clear_and_dispose(Disposer disposer); | |
686 | |
687 //! @copydoc ::boost::intrusive::bstree::count(const_reference)const | |
688 size_type count(const_reference value) const; | |
689 | |
690 //! @copydoc ::boost::intrusive::bstree::count(const KeyType&,KeyValueCompare)const | |
691 template<class KeyType, class KeyValueCompare> | |
692 size_type count(const KeyType& key, KeyValueCompare comp) const; | |
693 | |
694 //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference) | |
695 iterator lower_bound(const_reference value); | |
696 | |
697 //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare) | |
698 template<class KeyType, class KeyValueCompare> | |
699 iterator lower_bound(const KeyType& key, KeyValueCompare comp); | |
700 | |
701 //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference)const | |
702 const_iterator lower_bound(const_reference value) const; | |
703 | |
704 //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare)const | |
705 template<class KeyType, class KeyValueCompare> | |
706 const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const; | |
707 | |
708 //! @copydoc ::boost::intrusive::bstree::upper_bound(const_reference) | |
709 iterator upper_bound(const_reference value); | |
710 | |
711 //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyValueCompare) | |
712 template<class KeyType, class KeyValueCompare> | |
713 iterator upper_bound(const KeyType& key, KeyValueCompare comp); | |
714 | |
715 //! @copydoc ::boost::intrusive::bstree::upper_bound(const_reference)const | |
716 const_iterator upper_bound(const_reference value) const; | |
717 | |
718 //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyValueCompare)const | |
719 template<class KeyType, class KeyValueCompare> | |
720 const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const; | |
721 | |
722 //! @copydoc ::boost::intrusive::bstree::find(const_reference) | |
723 iterator find(const_reference value); | |
724 | |
725 //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyValueCompare) | |
726 template<class KeyType, class KeyValueCompare> | |
727 iterator find(const KeyType& key, KeyValueCompare comp); | |
728 | |
729 //! @copydoc ::boost::intrusive::bstree::find(const_reference)const | |
730 const_iterator find(const_reference value) const; | |
731 | |
732 //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyValueCompare)const | |
733 template<class KeyType, class KeyValueCompare> | |
734 const_iterator find(const KeyType& key, KeyValueCompare comp) const; | |
735 | |
736 //! @copydoc ::boost::intrusive::bstree::equal_range(const_reference) | |
737 std::pair<iterator,iterator> equal_range(const_reference value); | |
738 | |
739 //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyValueCompare) | |
740 template<class KeyType, class KeyValueCompare> | |
741 std::pair<iterator,iterator> equal_range(const KeyType& key, KeyValueCompare comp); | |
742 | |
743 //! @copydoc ::boost::intrusive::bstree::equal_range(const_reference)const | |
744 std::pair<const_iterator, const_iterator> | |
745 equal_range(const_reference value) const; | |
746 | |
747 //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyValueCompare)const | |
748 template<class KeyType, class KeyValueCompare> | |
749 std::pair<const_iterator, const_iterator> | |
750 equal_range(const KeyType& key, KeyValueCompare comp) const; | |
751 | |
752 //! @copydoc ::boost::intrusive::bstree::bounded_range(const_reference,const_reference,bool,bool) | |
753 std::pair<iterator,iterator> bounded_range | |
754 (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed); | |
755 | |
756 //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool) | |
757 template<class KeyType, class KeyValueCompare> | |
758 std::pair<iterator,iterator> bounded_range | |
759 (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed); | |
760 | |
761 //! @copydoc ::boost::intrusive::bstree::bounded_range(const_reference,const_reference,bool,bool)const | |
762 std::pair<const_iterator, const_iterator> | |
763 bounded_range(const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) const; | |
764 | |
765 //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool)const | |
766 template<class KeyType, class KeyValueCompare> | |
767 std::pair<const_iterator, const_iterator> bounded_range | |
768 (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) const; | |
769 | |
770 //! @copydoc ::boost::intrusive::bstree::s_iterator_to(reference) | |
771 static iterator s_iterator_to(reference value); | |
772 | |
773 //! @copydoc ::boost::intrusive::bstree::s_iterator_to(const_reference) | |
774 static const_iterator s_iterator_to(const_reference value); | |
775 | |
776 //! @copydoc ::boost::intrusive::bstree::iterator_to(reference) | |
777 iterator iterator_to(reference value); | |
778 | |
779 //! @copydoc ::boost::intrusive::bstree::iterator_to(const_reference)const | |
780 const_iterator iterator_to(const_reference value) const; | |
781 | |
782 //! @copydoc ::boost::intrusive::bstree::init_node(reference) | |
783 static void init_node(reference value); | |
784 | |
785 //! @copydoc ::boost::intrusive::bstree::unlink_leftmost_without_rebalance | |
786 pointer unlink_leftmost_without_rebalance(); | |
787 | |
788 //! @copydoc ::boost::intrusive::bstree::replace_node | |
789 void replace_node(iterator replace_this, reference with_this); | |
790 | |
791 //! @copydoc ::boost::intrusive::bstree::remove_node | |
792 void remove_node(reference value); | |
793 #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED | |
794 }; | |
795 | |
796 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
797 | |
798 template<class T, class ...Options> | |
799 bool operator!= (const bs_multiset_impl<T, Options...> &x, const bs_multiset_impl<T, Options...> &y); | |
800 | |
801 template<class T, class ...Options> | |
802 bool operator>(const bs_multiset_impl<T, Options...> &x, const bs_multiset_impl<T, Options...> &y); | |
803 | |
804 template<class T, class ...Options> | |
805 bool operator<=(const bs_multiset_impl<T, Options...> &x, const bs_multiset_impl<T, Options...> &y); | |
806 | |
807 template<class T, class ...Options> | |
808 bool operator>=(const bs_multiset_impl<T, Options...> &x, const bs_multiset_impl<T, Options...> &y); | |
809 | |
810 template<class T, class ...Options> | |
811 void swap(bs_multiset_impl<T, Options...> &x, bs_multiset_impl<T, Options...> &y); | |
812 | |
813 #endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
814 | |
815 //! Helper metafunction to define a \c bs_multiset that yields to the same type when the | |
816 //! same options (either explicitly or implicitly) are used. | |
817 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | |
818 template<class T, class ...Options> | |
819 #else | |
820 template<class T, class O1 = void, class O2 = void | |
821 , class O3 = void, class O4 = void> | |
822 #endif | |
823 struct make_bs_multiset | |
824 { | |
825 /// @cond | |
826 typedef typename pack_options | |
827 < bstree_defaults, | |
828 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | |
829 O1, O2, O3, O4 | |
830 #else | |
831 Options... | |
832 #endif | |
833 >::type packed_options; | |
834 | |
835 typedef typename detail::get_value_traits | |
836 <T, typename packed_options::proto_value_traits>::type value_traits; | |
837 | |
838 typedef bs_multiset_impl | |
839 < value_traits | |
840 , typename packed_options::compare | |
841 , typename packed_options::size_type | |
842 , packed_options::constant_time_size | |
843 > implementation_defined; | |
844 /// @endcond | |
845 typedef implementation_defined type; | |
846 }; | |
847 | |
848 #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED | |
849 | |
850 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | |
851 template<class T, class O1, class O2, class O3, class O4> | |
852 #else | |
853 template<class T, class ...Options> | |
854 #endif | |
855 class bs_multiset | |
856 : public make_bs_multiset<T, | |
857 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | |
858 O1, O2, O3, O4 | |
859 #else | |
860 Options... | |
861 #endif | |
862 >::type | |
863 { | |
864 typedef typename make_bs_multiset<T, | |
865 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | |
866 O1, O2, O3, O4 | |
867 #else | |
868 Options... | |
869 #endif | |
870 >::type Base; | |
871 | |
872 BOOST_MOVABLE_BUT_NOT_COPYABLE(bs_multiset) | |
873 | |
874 public: | |
875 typedef typename Base::value_compare value_compare; | |
876 typedef typename Base::value_traits value_traits; | |
877 typedef typename Base::iterator iterator; | |
878 typedef typename Base::const_iterator const_iterator; | |
879 | |
880 //Assert if passed value traits are compatible with the type | |
881 BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value)); | |
882 | |
883 explicit bs_multiset( const value_compare &cmp = value_compare() | |
884 , const value_traits &v_traits = value_traits()) | |
885 : Base(cmp, v_traits) | |
886 {} | |
887 | |
888 template<class Iterator> | |
889 bs_multiset( Iterator b, Iterator e | |
890 , const value_compare &cmp = value_compare() | |
891 , const value_traits &v_traits = value_traits()) | |
892 : Base(b, e, cmp, v_traits) | |
893 {} | |
894 | |
895 bs_multiset(BOOST_RV_REF(bs_multiset) x) | |
896 : Base(::boost::move(static_cast<Base&>(x))) | |
897 {} | |
898 | |
899 bs_multiset& operator=(BOOST_RV_REF(bs_multiset) x) | |
900 { return static_cast<bs_multiset &>(this->Base::operator=(::boost::move(static_cast<Base&>(x)))); } | |
901 | |
902 static bs_multiset &container_from_end_iterator(iterator end_iterator) | |
903 { return static_cast<bs_multiset &>(Base::container_from_end_iterator(end_iterator)); } | |
904 | |
905 static const bs_multiset &container_from_end_iterator(const_iterator end_iterator) | |
906 { return static_cast<const bs_multiset &>(Base::container_from_end_iterator(end_iterator)); } | |
907 | |
908 static bs_multiset &container_from_iterator(iterator it) | |
909 { return static_cast<bs_multiset &>(Base::container_from_iterator(it)); } | |
910 | |
911 static const bs_multiset &container_from_iterator(const_iterator it) | |
912 { return static_cast<const bs_multiset &>(Base::container_from_iterator(it)); } | |
913 }; | |
914 | |
915 #endif | |
916 | |
917 } //namespace intrusive | |
918 } //namespace boost | |
919 | |
920 #include <boost/intrusive/detail/config_end.hpp> | |
921 | |
922 #endif //BOOST_INTRUSIVE_BS_SET_HPP |