Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/intrusive/bstree.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_BSTREE_HPP | |
13 #define BOOST_INTRUSIVE_BSTREE_HPP | |
14 | |
15 #include <boost/intrusive/detail/config_begin.hpp> | |
16 #include <algorithm> | |
17 #include <cstddef> | |
18 #include <functional> | |
19 #include <iterator> | |
20 #include <utility> | |
21 | |
22 #include <boost/intrusive/detail/assert.hpp> | |
23 #include <boost/static_assert.hpp> | |
24 #include <boost/intrusive/intrusive_fwd.hpp> | |
25 #include <boost/intrusive/set_hook.hpp> | |
26 #include <boost/intrusive/detail/tree_node.hpp> | |
27 #include <boost/intrusive/detail/ebo_functor_holder.hpp> | |
28 #include <boost/intrusive/detail/mpl.hpp> | |
29 #include <boost/intrusive/pointer_traits.hpp> | |
30 #include <boost/intrusive/detail/clear_on_destructor_base.hpp> | |
31 #include <boost/intrusive/detail/function_detector.hpp> | |
32 #include <boost/intrusive/detail/utilities.hpp> | |
33 #include <boost/intrusive/options.hpp> | |
34 #include <boost/intrusive/bstree_algorithms.hpp> | |
35 #include <boost/intrusive/link_mode.hpp> | |
36 #include <boost/move/move.hpp> | |
37 | |
38 namespace boost { | |
39 namespace intrusive { | |
40 | |
41 /// @cond | |
42 | |
43 struct bstree_defaults | |
44 { | |
45 typedef detail::default_bstree_hook proto_value_traits; | |
46 static const bool constant_time_size = true; | |
47 typedef std::size_t size_type; | |
48 typedef void compare; | |
49 static const bool floating_point = true; //For sgtree | |
50 typedef void priority; //For treap | |
51 }; | |
52 | |
53 template<class ValueTraits, algo_types AlgoType> | |
54 struct bstbase3 | |
55 : public detail::get_real_value_traits<ValueTraits>::type::node_traits::node | |
56 , public ValueTraits | |
57 { | |
58 typedef ValueTraits value_traits; | |
59 typedef typename detail::get_real_value_traits<ValueTraits>::type real_value_traits; | |
60 typedef typename real_value_traits::node_traits node_traits; | |
61 typedef typename node_traits::node node_type; | |
62 typedef typename get_algo<AlgoType, node_traits>::type node_algorithms; | |
63 typedef typename node_traits::node_ptr node_ptr; | |
64 typedef typename node_traits::const_node_ptr const_node_ptr; | |
65 | |
66 bstbase3(const ValueTraits &vtraits) | |
67 : ValueTraits(vtraits) | |
68 {} | |
69 | |
70 static const bool external_value_traits = | |
71 detail::external_value_traits_bool_is_true<ValueTraits>::value; | |
72 | |
73 node_ptr header_ptr() | |
74 { return pointer_traits<node_ptr>::pointer_to(static_cast<node_type&>(*this)); } | |
75 | |
76 const_node_ptr header_ptr() const | |
77 { return pointer_traits<const_node_ptr>::pointer_to(static_cast<const node_type&>(*this)); } | |
78 | |
79 const value_traits &val_traits() const | |
80 { return *this; } | |
81 | |
82 value_traits &val_traits() | |
83 { return *this; } | |
84 | |
85 const real_value_traits &get_real_value_traits(detail::bool_<false>) const | |
86 { return *this; } | |
87 | |
88 const real_value_traits &get_real_value_traits(detail::bool_<true>) const | |
89 { return this->val_traits().get_value_traits(*this); } | |
90 | |
91 real_value_traits &get_real_value_traits(detail::bool_<false>) | |
92 { return *this; } | |
93 | |
94 real_value_traits &get_real_value_traits(detail::bool_<true>) | |
95 { return this->val_traits().get_value_traits(*this); } | |
96 | |
97 const real_value_traits &get_real_value_traits() const | |
98 { return this->get_real_value_traits(detail::bool_<external_value_traits>()); } | |
99 | |
100 real_value_traits &get_real_value_traits() | |
101 { return this->get_real_value_traits(detail::bool_<external_value_traits>()); } | |
102 | |
103 typedef typename pointer_traits<node_ptr>::template rebind_pointer<const real_value_traits>::type const_real_value_traits_ptr; | |
104 | |
105 const_real_value_traits_ptr real_value_traits_ptr() const | |
106 { return pointer_traits<const_real_value_traits_ptr>::pointer_to(this->get_real_value_traits()); } | |
107 | |
108 | |
109 typedef tree_iterator<real_value_traits, false> iterator; | |
110 typedef tree_iterator<real_value_traits, true> const_iterator; | |
111 typedef boost::intrusive::detail::reverse_iterator<iterator> reverse_iterator; | |
112 typedef boost::intrusive::detail::reverse_iterator<const_iterator> const_reverse_iterator; | |
113 typedef BOOST_INTRUSIVE_IMPDEF(typename real_value_traits::pointer) pointer; | |
114 typedef BOOST_INTRUSIVE_IMPDEF(typename real_value_traits::const_pointer) const_pointer; | |
115 typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<pointer>::element_type) value_type; | |
116 typedef BOOST_INTRUSIVE_IMPDEF(value_type) key_type; | |
117 typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<pointer>::reference) reference; | |
118 typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<const_pointer>::reference) const_reference; | |
119 typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<const_pointer>::difference_type) difference_type; | |
120 static const bool safemode_or_autounlink = is_safe_autounlink<real_value_traits::link_mode>::value; | |
121 static const bool stateful_value_traits = detail::is_stateful_value_traits<real_value_traits>::value; | |
122 | |
123 iterator begin() | |
124 { return iterator (node_traits::get_left(this->header_ptr()), this->real_value_traits_ptr()); } | |
125 | |
126 const_iterator begin() const | |
127 { return cbegin(); } | |
128 | |
129 const_iterator cbegin() const | |
130 { return const_iterator (node_traits::get_left(this->header_ptr()), this->real_value_traits_ptr()); } | |
131 | |
132 iterator end() | |
133 { return iterator (this->header_ptr(), this->real_value_traits_ptr()); } | |
134 | |
135 const_iterator end() const | |
136 { return cend(); } | |
137 | |
138 const_iterator cend() const | |
139 { return const_iterator (detail::uncast(this->header_ptr()), this->real_value_traits_ptr()); } | |
140 | |
141 reverse_iterator rbegin() | |
142 { return reverse_iterator(end()); } | |
143 | |
144 const_reverse_iterator rbegin() const | |
145 { return const_reverse_iterator(end()); } | |
146 | |
147 const_reverse_iterator crbegin() const | |
148 { return const_reverse_iterator(end()); } | |
149 | |
150 reverse_iterator rend() | |
151 { return reverse_iterator(begin()); } | |
152 | |
153 const_reverse_iterator rend() const | |
154 { return const_reverse_iterator(begin()); } | |
155 | |
156 const_reverse_iterator crend() const | |
157 { return const_reverse_iterator(begin()); } | |
158 | |
159 void replace_node(iterator replace_this, reference with_this) | |
160 { | |
161 node_algorithms::replace_node( get_real_value_traits().to_node_ptr(*replace_this) | |
162 , this->header_ptr() | |
163 , get_real_value_traits().to_node_ptr(with_this)); | |
164 if(safemode_or_autounlink) | |
165 node_algorithms::init(replace_this.pointed_node()); | |
166 } | |
167 | |
168 void rebalance() | |
169 { node_algorithms::rebalance(this->header_ptr()); } | |
170 | |
171 iterator rebalance_subtree(iterator root) | |
172 { return iterator(node_algorithms::rebalance_subtree(root.pointed_node()), this->real_value_traits_ptr()); } | |
173 | |
174 static iterator s_iterator_to(reference value) | |
175 { | |
176 BOOST_STATIC_ASSERT((!stateful_value_traits)); | |
177 return iterator (value_traits::to_node_ptr(value), const_real_value_traits_ptr()); | |
178 } | |
179 | |
180 static const_iterator s_iterator_to(const_reference value) | |
181 { | |
182 BOOST_STATIC_ASSERT((!stateful_value_traits)); | |
183 return const_iterator (value_traits::to_node_ptr(const_cast<reference> (value)), const_real_value_traits_ptr()); | |
184 } | |
185 | |
186 iterator iterator_to(reference value) | |
187 { return iterator (value_traits::to_node_ptr(value), this->real_value_traits_ptr()); } | |
188 | |
189 const_iterator iterator_to(const_reference value) const | |
190 { return const_iterator (value_traits::to_node_ptr(const_cast<reference> (value)), this->real_value_traits_ptr()); } | |
191 | |
192 static void init_node(reference value) | |
193 { node_algorithms::init(value_traits::to_node_ptr(value)); } | |
194 | |
195 }; | |
196 | |
197 template<class ValueTraits, class VoidOrKeyComp, algo_types AlgoType> | |
198 struct bstbase2 | |
199 : public bstbase3<ValueTraits, AlgoType> | |
200 , public detail::ebo_functor_holder<typename get_less< VoidOrKeyComp | |
201 , typename detail::get_real_value_traits<ValueTraits>::type::value_type | |
202 >::type> | |
203 { | |
204 typedef bstbase3<ValueTraits, AlgoType> treeheader_t; | |
205 typedef typename treeheader_t::real_value_traits real_value_traits; | |
206 typedef typename treeheader_t::node_algorithms node_algorithms; | |
207 typedef typename get_less | |
208 < VoidOrKeyComp, typename real_value_traits::value_type>::type value_compare; | |
209 typedef BOOST_INTRUSIVE_IMPDEF(value_compare) key_compare; | |
210 typedef typename treeheader_t::iterator iterator; | |
211 typedef typename treeheader_t::const_iterator const_iterator; | |
212 typedef typename treeheader_t::node_ptr node_ptr; | |
213 typedef typename treeheader_t::const_node_ptr const_node_ptr; | |
214 | |
215 bstbase2(const value_compare &comp, const ValueTraits &vtraits) | |
216 : treeheader_t(vtraits), detail::ebo_functor_holder<value_compare>(comp) | |
217 {} | |
218 | |
219 const value_compare &comp() const | |
220 { return this->get(); } | |
221 | |
222 value_compare &comp() | |
223 { return this->get(); } | |
224 | |
225 typedef BOOST_INTRUSIVE_IMPDEF(typename real_value_traits::pointer) pointer; | |
226 typedef BOOST_INTRUSIVE_IMPDEF(typename real_value_traits::const_pointer) const_pointer; | |
227 typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<pointer>::element_type) value_type; | |
228 typedef BOOST_INTRUSIVE_IMPDEF(value_type) key_type; | |
229 typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<pointer>::reference) reference; | |
230 typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<const_pointer>::reference) const_reference; | |
231 typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<const_pointer>::difference_type) difference_type; | |
232 typedef typename node_algorithms::insert_commit_data insert_commit_data; | |
233 | |
234 value_compare value_comp() const | |
235 { return this->comp(); } | |
236 | |
237 key_compare key_comp() const | |
238 { return this->comp(); } | |
239 | |
240 iterator lower_bound(const_reference value) | |
241 { return this->lower_bound(value, this->comp()); } | |
242 | |
243 const_iterator lower_bound(const_reference value) const | |
244 { return this->lower_bound(value, this->comp()); } | |
245 | |
246 template<class KeyType, class KeyValueCompare> | |
247 iterator lower_bound(const KeyType &key, KeyValueCompare comp) | |
248 { | |
249 detail::key_nodeptr_comp<KeyValueCompare, real_value_traits> | |
250 key_node_comp(comp, &this->get_real_value_traits()); | |
251 return iterator(node_algorithms::lower_bound | |
252 (this->header_ptr(), key, key_node_comp), this->real_value_traits_ptr()); | |
253 } | |
254 | |
255 template<class KeyType, class KeyValueCompare> | |
256 const_iterator lower_bound(const KeyType &key, KeyValueCompare comp) const | |
257 { | |
258 detail::key_nodeptr_comp<KeyValueCompare, real_value_traits> | |
259 key_node_comp(comp, &this->get_real_value_traits()); | |
260 return const_iterator(node_algorithms::lower_bound | |
261 (this->header_ptr(), key, key_node_comp), this->real_value_traits_ptr()); | |
262 } | |
263 | |
264 iterator upper_bound(const_reference value) | |
265 { return this->upper_bound(value, this->comp()); } | |
266 | |
267 template<class KeyType, class KeyValueCompare> | |
268 iterator upper_bound(const KeyType &key, KeyValueCompare comp) | |
269 { | |
270 detail::key_nodeptr_comp<KeyValueCompare, real_value_traits> | |
271 key_node_comp(comp, &this->get_real_value_traits()); | |
272 return iterator(node_algorithms::upper_bound | |
273 (this->header_ptr(), key, key_node_comp), this->real_value_traits_ptr()); | |
274 } | |
275 | |
276 const_iterator upper_bound(const_reference value) const | |
277 { return this->upper_bound(value, this->comp()); } | |
278 | |
279 template<class KeyType, class KeyValueCompare> | |
280 const_iterator upper_bound(const KeyType &key, KeyValueCompare comp) const | |
281 { | |
282 detail::key_nodeptr_comp<KeyValueCompare, real_value_traits> | |
283 key_node_comp(comp, &this->get_real_value_traits()); | |
284 return const_iterator(node_algorithms::upper_bound | |
285 (this->header_ptr(), key, key_node_comp), this->real_value_traits_ptr()); | |
286 } | |
287 | |
288 iterator find(const_reference value) | |
289 { return this->find(value, this->comp()); } | |
290 | |
291 template<class KeyType, class KeyValueCompare> | |
292 iterator find(const KeyType &key, KeyValueCompare comp) | |
293 { | |
294 detail::key_nodeptr_comp<KeyValueCompare, real_value_traits> | |
295 key_node_comp(comp, &this->get_real_value_traits()); | |
296 return iterator | |
297 (node_algorithms::find(this->header_ptr(), key, key_node_comp), this->real_value_traits_ptr()); | |
298 } | |
299 | |
300 const_iterator find(const_reference value) const | |
301 { return this->find(value, this->comp()); } | |
302 | |
303 template<class KeyType, class KeyValueCompare> | |
304 const_iterator find(const KeyType &key, KeyValueCompare comp) const | |
305 { | |
306 detail::key_nodeptr_comp<KeyValueCompare, real_value_traits> | |
307 key_node_comp(comp, &this->get_real_value_traits()); | |
308 return const_iterator | |
309 (node_algorithms::find(this->header_ptr(), key, key_node_comp), this->real_value_traits_ptr()); | |
310 } | |
311 | |
312 std::pair<iterator,iterator> equal_range(const_reference value) | |
313 { return this->equal_range(value, this->comp()); } | |
314 | |
315 template<class KeyType, class KeyValueCompare> | |
316 std::pair<iterator,iterator> equal_range(const KeyType &key, KeyValueCompare comp) | |
317 { | |
318 detail::key_nodeptr_comp<KeyValueCompare, real_value_traits> | |
319 key_node_comp(comp, &this->get_real_value_traits()); | |
320 std::pair<node_ptr, node_ptr> ret | |
321 (node_algorithms::equal_range(this->header_ptr(), key, key_node_comp)); | |
322 return std::pair<iterator, iterator>( iterator(ret.first, this->real_value_traits_ptr()) | |
323 , iterator(ret.second, this->real_value_traits_ptr())); | |
324 } | |
325 | |
326 std::pair<const_iterator, const_iterator> | |
327 equal_range(const_reference value) const | |
328 { return this->equal_range(value, this->comp()); } | |
329 | |
330 template<class KeyType, class KeyValueCompare> | |
331 std::pair<const_iterator, const_iterator> | |
332 equal_range(const KeyType &key, KeyValueCompare comp) const | |
333 { | |
334 detail::key_nodeptr_comp<KeyValueCompare, real_value_traits> | |
335 key_node_comp(comp, &this->get_real_value_traits()); | |
336 std::pair<node_ptr, node_ptr> ret | |
337 (node_algorithms::equal_range(this->header_ptr(), key, key_node_comp)); | |
338 return std::pair<const_iterator, const_iterator>( const_iterator(ret.first, this->real_value_traits_ptr()) | |
339 , const_iterator(ret.second, this->real_value_traits_ptr())); | |
340 } | |
341 | |
342 std::pair<iterator,iterator> bounded_range | |
343 (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) | |
344 { return this->bounded_range(lower_value, upper_value, this->comp(), left_closed, right_closed); } | |
345 | |
346 template<class KeyType, class KeyValueCompare> | |
347 std::pair<iterator,iterator> bounded_range | |
348 (const KeyType &lower_key, const KeyType &upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) | |
349 { | |
350 detail::key_nodeptr_comp<KeyValueCompare, real_value_traits> | |
351 key_node_comp(comp, &this->get_real_value_traits()); | |
352 std::pair<node_ptr, node_ptr> ret | |
353 (node_algorithms::bounded_range | |
354 (this->header_ptr(), lower_key, upper_key, key_node_comp, left_closed, right_closed)); | |
355 return std::pair<iterator, iterator>( iterator(ret.first, this->real_value_traits_ptr()) | |
356 , iterator(ret.second, this->real_value_traits_ptr())); | |
357 } | |
358 | |
359 std::pair<const_iterator,const_iterator> bounded_range | |
360 (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) const | |
361 { return this->bounded_range(lower_value, upper_value, this->comp(), left_closed, right_closed); } | |
362 | |
363 template<class KeyType, class KeyValueCompare> | |
364 std::pair<const_iterator,const_iterator> bounded_range | |
365 (const KeyType &lower_key, const KeyType &upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) const | |
366 { | |
367 detail::key_nodeptr_comp<KeyValueCompare, real_value_traits> | |
368 key_node_comp(comp, &this->get_real_value_traits()); | |
369 std::pair<node_ptr, node_ptr> ret | |
370 (node_algorithms::bounded_range | |
371 (this->header_ptr(), lower_key, upper_key, key_node_comp, left_closed, right_closed)); | |
372 return std::pair<const_iterator, const_iterator>( const_iterator(ret.first, this->real_value_traits_ptr()) | |
373 , const_iterator(ret.second, this->real_value_traits_ptr())); | |
374 } | |
375 | |
376 template<class KeyType, class KeyValueCompare> | |
377 std::pair<iterator, bool> insert_unique_check | |
378 (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data) | |
379 { | |
380 detail::key_nodeptr_comp<KeyValueCompare, real_value_traits> | |
381 ocomp(key_value_comp, &this->get_real_value_traits()); | |
382 std::pair<node_ptr, bool> ret = | |
383 (node_algorithms::insert_unique_check | |
384 (this->header_ptr(), key, ocomp, commit_data)); | |
385 return std::pair<iterator, bool>(iterator(ret.first, this->real_value_traits_ptr()), ret.second); | |
386 } | |
387 | |
388 template<class KeyType, class KeyValueCompare> | |
389 std::pair<iterator, bool> insert_unique_check | |
390 (const_iterator hint, const KeyType &key | |
391 ,KeyValueCompare key_value_comp, insert_commit_data &commit_data) | |
392 { | |
393 detail::key_nodeptr_comp<KeyValueCompare, real_value_traits> | |
394 ocomp(key_value_comp, &this->get_real_value_traits()); | |
395 std::pair<node_ptr, bool> ret = | |
396 (node_algorithms::insert_unique_check | |
397 (this->header_ptr(), hint.pointed_node(), key, ocomp, commit_data)); | |
398 return std::pair<iterator, bool>(iterator(ret.first, this->real_value_traits_ptr()), ret.second); | |
399 } | |
400 }; | |
401 | |
402 template<class ValueTraits, class VoidOrKeyComp, bool ConstantTimeSize, class SizeType, algo_types AlgoType> | |
403 struct bstbase | |
404 : public detail::size_holder<ConstantTimeSize, SizeType> | |
405 , public bstbase2 < ValueTraits, VoidOrKeyComp, AlgoType> | |
406 { | |
407 typedef typename detail::get_real_value_traits<ValueTraits>::type real_value_traits; | |
408 typedef bstbase2< ValueTraits, VoidOrKeyComp, AlgoType> base_type; | |
409 typedef typename base_type::value_compare value_compare; | |
410 typedef BOOST_INTRUSIVE_IMPDEF(value_compare) key_compare; | |
411 typedef typename base_type::const_reference const_reference; | |
412 typedef typename base_type::reference reference; | |
413 typedef typename base_type::iterator iterator; | |
414 typedef typename base_type::const_iterator const_iterator; | |
415 typedef typename base_type::node_traits node_traits; | |
416 typedef typename get_algo | |
417 <AlgoType, node_traits>::type algo_type; | |
418 typedef SizeType size_type; | |
419 | |
420 bstbase(const value_compare & comp, const ValueTraits &vtraits) | |
421 : base_type(comp, vtraits) | |
422 {} | |
423 | |
424 public: | |
425 typedef detail::size_holder<ConstantTimeSize, SizeType> size_traits; | |
426 | |
427 size_traits &sz_traits() | |
428 { return *this; } | |
429 | |
430 const size_traits &sz_traits() const | |
431 { return *this; } | |
432 | |
433 size_type count(const_reference value) const | |
434 { return size_type(this->count(value, this->comp())); } | |
435 | |
436 template<class KeyType, class KeyValueCompare> | |
437 size_type count(const KeyType &key, KeyValueCompare comp) const | |
438 { | |
439 std::pair<const_iterator, const_iterator> ret = this->equal_range(key, comp); | |
440 return size_type(std::distance(ret.first, ret.second)); | |
441 } | |
442 | |
443 bool empty() const | |
444 { | |
445 if(ConstantTimeSize){ | |
446 return !this->sz_traits().get_size(); | |
447 } | |
448 else{ | |
449 return algo_type::unique(this->header_ptr()); | |
450 } | |
451 } | |
452 }; | |
453 | |
454 | |
455 /// @endcond | |
456 | |
457 //! The class template bstree is an unbalanced intrusive binary search tree | |
458 //! container. The no-throw guarantee holds only, if the value_compare object | |
459 //! doesn't throw. | |
460 //! | |
461 //! The complexity guarantees only hold if the tree is balanced, logarithmic | |
462 //! complexity would increase to linear if the tree is totally unbalanced. | |
463 //! | |
464 //! The template parameter \c T is the type to be managed by the container. | |
465 //! The user can specify additional options and if no options are provided | |
466 //! default options are used. | |
467 //! | |
468 //! The container supports the following options: | |
469 //! \c base_hook<>/member_hook<>/value_traits<>, | |
470 //! \c constant_time_size<>, \c size_type<> and | |
471 //! \c compare<>. | |
472 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
473 template<class T, class ...Options> | |
474 #else | |
475 template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType> | |
476 #endif | |
477 class bstree_impl | |
478 : public bstbase<ValueTraits, VoidKeyComp, ConstantTimeSize, SizeType, AlgoType> | |
479 , private detail::clear_on_destructor_base | |
480 < bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> | |
481 , is_safe_autounlink<detail::get_real_value_traits<ValueTraits>::type::link_mode>::value | |
482 > | |
483 { | |
484 template<class C, bool> friend class detail::clear_on_destructor_base; | |
485 public: | |
486 typedef ValueTraits value_traits; | |
487 /// @cond | |
488 static const bool external_value_traits = | |
489 detail::external_value_traits_bool_is_true<value_traits>::value; | |
490 typedef typename detail::get_real_value_traits<ValueTraits>::type real_value_traits; | |
491 typedef bstbase<value_traits, VoidKeyComp, ConstantTimeSize, SizeType, AlgoType> data_type; | |
492 typedef tree_iterator<real_value_traits, false> iterator_type; | |
493 typedef tree_iterator<real_value_traits, true> const_iterator_type; | |
494 /// @endcond | |
495 | |
496 typedef BOOST_INTRUSIVE_IMPDEF(typename real_value_traits::pointer) pointer; | |
497 typedef BOOST_INTRUSIVE_IMPDEF(typename real_value_traits::const_pointer) const_pointer; | |
498 typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<pointer>::element_type) value_type; | |
499 typedef BOOST_INTRUSIVE_IMPDEF(value_type) key_type; | |
500 typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<pointer>::reference) reference; | |
501 typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<const_pointer>::reference) const_reference; | |
502 typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<const_pointer>::difference_type) difference_type; | |
503 typedef BOOST_INTRUSIVE_IMPDEF(SizeType) size_type; | |
504 typedef BOOST_INTRUSIVE_IMPDEF(typename data_type::value_compare) value_compare; | |
505 typedef BOOST_INTRUSIVE_IMPDEF(value_compare) key_compare; | |
506 typedef BOOST_INTRUSIVE_IMPDEF(iterator_type) iterator; | |
507 typedef BOOST_INTRUSIVE_IMPDEF(const_iterator_type) const_iterator; | |
508 typedef BOOST_INTRUSIVE_IMPDEF(boost::intrusive::detail::reverse_iterator<iterator>) reverse_iterator; | |
509 typedef BOOST_INTRUSIVE_IMPDEF(boost::intrusive::detail::reverse_iterator<const_iterator>) const_reverse_iterator; | |
510 typedef BOOST_INTRUSIVE_IMPDEF(typename real_value_traits::node_traits) node_traits; | |
511 typedef BOOST_INTRUSIVE_IMPDEF(typename node_traits::node) node; | |
512 typedef BOOST_INTRUSIVE_IMPDEF(typename node_traits::node_ptr) node_ptr; | |
513 typedef BOOST_INTRUSIVE_IMPDEF(typename node_traits::const_node_ptr) const_node_ptr; | |
514 /// @cond | |
515 typedef typename get_algo<AlgoType, node_traits>::type algo_type; | |
516 /// @endcond | |
517 typedef BOOST_INTRUSIVE_IMPDEF(algo_type) node_algorithms; | |
518 | |
519 static const bool constant_time_size = ConstantTimeSize; | |
520 static const bool stateful_value_traits = detail::is_stateful_value_traits<real_value_traits>::value; | |
521 /// @cond | |
522 private: | |
523 | |
524 //noncopyable | |
525 BOOST_MOVABLE_BUT_NOT_COPYABLE(bstree_impl) | |
526 | |
527 static const bool safemode_or_autounlink = is_safe_autounlink<real_value_traits::link_mode>::value; | |
528 | |
529 //Constant-time size is incompatible with auto-unlink hooks! | |
530 BOOST_STATIC_ASSERT(!(constant_time_size && ((int)real_value_traits::link_mode == (int)auto_unlink))); | |
531 | |
532 | |
533 protected: | |
534 | |
535 | |
536 /// @endcond | |
537 | |
538 public: | |
539 | |
540 typedef typename node_algorithms::insert_commit_data insert_commit_data; | |
541 | |
542 //! <b>Effects</b>: Constructs an empty container. | |
543 //! | |
544 //! <b>Complexity</b>: Constant. | |
545 //! | |
546 //! <b>Throws</b>: If value_traits::node_traits::node | |
547 //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) | |
548 //! or the copy constructorof the value_compare object throws. Basic guarantee. | |
549 explicit bstree_impl( const value_compare &cmp = value_compare() | |
550 , const value_traits &v_traits = value_traits()) | |
551 : data_type(cmp, v_traits) | |
552 { | |
553 node_algorithms::init_header(this->header_ptr()); | |
554 this->sz_traits().set_size(size_type(0)); | |
555 } | |
556 | |
557 //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type. | |
558 //! cmp must be a comparison function that induces a strict weak ordering. | |
559 //! | |
560 //! <b>Effects</b>: Constructs an empty container and inserts elements from | |
561 //! [b, e). | |
562 //! | |
563 //! <b>Complexity</b>: Linear in N if [b, e) is already sorted using | |
564 //! comp and otherwise N * log N, where N is the distance between first and last. | |
565 //! | |
566 //! <b>Throws</b>: If value_traits::node_traits::node | |
567 //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) | |
568 //! or the copy constructor/operator() of the value_compare object throws. Basic guarantee. | |
569 template<class Iterator> | |
570 bstree_impl( bool unique, Iterator b, Iterator e | |
571 , const value_compare &cmp = value_compare() | |
572 , const value_traits &v_traits = value_traits()) | |
573 : data_type(cmp, v_traits) | |
574 { | |
575 node_algorithms::init_header(this->header_ptr()); | |
576 this->sz_traits().set_size(size_type(0)); | |
577 if(unique) | |
578 this->insert_unique(b, e); | |
579 else | |
580 this->insert_equal(b, e); | |
581 } | |
582 | |
583 //! <b>Effects</b>: to-do | |
584 //! | |
585 bstree_impl(BOOST_RV_REF(bstree_impl) x) | |
586 : data_type(::boost::move(x.comp()), ::boost::move(x.val_traits())) | |
587 { | |
588 node_algorithms::init_header(this->header_ptr()); | |
589 this->sz_traits().set_size(size_type(0)); | |
590 this->swap(x); | |
591 } | |
592 | |
593 //! <b>Effects</b>: to-do | |
594 //! | |
595 bstree_impl& operator=(BOOST_RV_REF(bstree_impl) x) | |
596 { this->swap(x); return *this; } | |
597 | |
598 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED | |
599 //! <b>Effects</b>: Detaches all elements from this. The objects in the set | |
600 //! are not deleted (i.e. no destructors are called), but the nodes according to | |
601 //! the value_traits template parameter are reinitialized and thus can be reused. | |
602 //! | |
603 //! <b>Complexity</b>: Linear to elements contained in *this. | |
604 //! | |
605 //! <b>Throws</b>: Nothing. | |
606 ~bstree_impl() | |
607 {} | |
608 | |
609 //! <b>Effects</b>: Returns an iterator pointing to the beginning of the container. | |
610 //! | |
611 //! <b>Complexity</b>: Constant. | |
612 //! | |
613 //! <b>Throws</b>: Nothing. | |
614 iterator begin(); | |
615 | |
616 //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the container. | |
617 //! | |
618 //! <b>Complexity</b>: Constant. | |
619 //! | |
620 //! <b>Throws</b>: Nothing. | |
621 const_iterator begin() const; | |
622 | |
623 //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the container. | |
624 //! | |
625 //! <b>Complexity</b>: Constant. | |
626 //! | |
627 //! <b>Throws</b>: Nothing. | |
628 const_iterator cbegin() const; | |
629 | |
630 //! <b>Effects</b>: Returns an iterator pointing to the end of the container. | |
631 //! | |
632 //! <b>Complexity</b>: Constant. | |
633 //! | |
634 //! <b>Throws</b>: Nothing. | |
635 iterator end(); | |
636 | |
637 //! <b>Effects</b>: Returns a const_iterator pointing to the end of the container. | |
638 //! | |
639 //! <b>Complexity</b>: Constant. | |
640 //! | |
641 //! <b>Throws</b>: Nothing. | |
642 const_iterator end() const; | |
643 | |
644 //! <b>Effects</b>: Returns a const_iterator pointing to the end of the container. | |
645 //! | |
646 //! <b>Complexity</b>: Constant. | |
647 //! | |
648 //! <b>Throws</b>: Nothing. | |
649 const_iterator cend() const; | |
650 | |
651 //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning of the | |
652 //! reversed container. | |
653 //! | |
654 //! <b>Complexity</b>: Constant. | |
655 //! | |
656 //! <b>Throws</b>: Nothing. | |
657 reverse_iterator rbegin(); | |
658 | |
659 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning | |
660 //! of the reversed container. | |
661 //! | |
662 //! <b>Complexity</b>: Constant. | |
663 //! | |
664 //! <b>Throws</b>: Nothing. | |
665 const_reverse_iterator rbegin() const; | |
666 | |
667 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning | |
668 //! of the reversed container. | |
669 //! | |
670 //! <b>Complexity</b>: Constant. | |
671 //! | |
672 //! <b>Throws</b>: Nothing. | |
673 const_reverse_iterator crbegin() const; | |
674 | |
675 //! <b>Effects</b>: Returns a reverse_iterator pointing to the end | |
676 //! of the reversed container. | |
677 //! | |
678 //! <b>Complexity</b>: Constant. | |
679 //! | |
680 //! <b>Throws</b>: Nothing. | |
681 reverse_iterator rend(); | |
682 | |
683 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end | |
684 //! of the reversed container. | |
685 //! | |
686 //! <b>Complexity</b>: Constant. | |
687 //! | |
688 //! <b>Throws</b>: Nothing. | |
689 const_reverse_iterator rend() const; | |
690 | |
691 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end | |
692 //! of the reversed container. | |
693 //! | |
694 //! <b>Complexity</b>: Constant. | |
695 //! | |
696 //! <b>Throws</b>: Nothing. | |
697 const_reverse_iterator crend() const; | |
698 | |
699 #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED | |
700 | |
701 //! <b>Precondition</b>: end_iterator must be a valid end iterator | |
702 //! of the container. | |
703 //! | |
704 //! <b>Effects</b>: Returns a const reference to the container associated to the end iterator | |
705 //! | |
706 //! <b>Throws</b>: Nothing. | |
707 //! | |
708 //! <b>Complexity</b>: Constant. | |
709 static bstree_impl &container_from_end_iterator(iterator end_iterator) | |
710 { | |
711 return *static_cast<bstree_impl*> | |
712 (boost::intrusive::detail::to_raw_pointer(end_iterator.pointed_node())); | |
713 } | |
714 | |
715 //! <b>Precondition</b>: end_iterator must be a valid end const_iterator | |
716 //! of the container. | |
717 //! | |
718 //! <b>Effects</b>: Returns a const reference to the container associated to the iterator | |
719 //! | |
720 //! <b>Throws</b>: Nothing. | |
721 //! | |
722 //! <b>Complexity</b>: Constant. | |
723 static const bstree_impl &container_from_end_iterator(const_iterator end_iterator) | |
724 { | |
725 return *static_cast<const bstree_impl*> | |
726 (boost::intrusive::detail::to_raw_pointer(end_iterator.pointed_node())); | |
727 } | |
728 | |
729 //! <b>Precondition</b>: it must be a valid iterator | |
730 //! of the container. | |
731 //! | |
732 //! <b>Effects</b>: Returns a const reference to the container associated to the iterator | |
733 //! | |
734 //! <b>Throws</b>: Nothing. | |
735 //! | |
736 //! <b>Complexity</b>: Logarithmic. | |
737 static bstree_impl &container_from_iterator(iterator it) | |
738 { return container_from_end_iterator(it.end_iterator_from_it()); } | |
739 | |
740 //! <b>Precondition</b>: it must be a valid end const_iterator | |
741 //! of container. | |
742 //! | |
743 //! <b>Effects</b>: Returns a const reference to the container associated to the end iterator | |
744 //! | |
745 //! <b>Throws</b>: Nothing. | |
746 //! | |
747 //! <b>Complexity</b>: Logarithmic. | |
748 static const bstree_impl &container_from_iterator(const_iterator it) | |
749 { return container_from_end_iterator(it.end_iterator_from_it()); } | |
750 | |
751 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED | |
752 | |
753 //! <b>Effects</b>: Returns the key_compare object used by the container. | |
754 //! | |
755 //! <b>Complexity</b>: Constant. | |
756 //! | |
757 //! <b>Throws</b>: If value_compare copy-constructor throws. | |
758 key_compare key_comp() const; | |
759 | |
760 //! <b>Effects</b>: Returns the value_compare object used by the container. | |
761 //! | |
762 //! <b>Complexity</b>: Constant. | |
763 //! | |
764 //! <b>Throws</b>: If value_compare copy-constructor throws. | |
765 value_compare value_comp() const; | |
766 | |
767 //! <b>Effects</b>: Returns true if the container is empty. | |
768 //! | |
769 //! <b>Complexity</b>: Constant. | |
770 //! | |
771 //! <b>Throws</b>: Nothing. | |
772 bool empty() const; | |
773 | |
774 #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED | |
775 | |
776 //! <b>Effects</b>: Returns the number of elements stored in the container. | |
777 //! | |
778 //! <b>Complexity</b>: Linear to elements contained in *this | |
779 //! if constant-time size option is disabled. Constant time otherwise. | |
780 //! | |
781 //! <b>Throws</b>: Nothing. | |
782 size_type size() const | |
783 { | |
784 if(constant_time_size) | |
785 return this->sz_traits().get_size(); | |
786 else{ | |
787 return (size_type)node_algorithms::size(this->header_ptr()); | |
788 } | |
789 } | |
790 | |
791 //! <b>Effects</b>: Swaps the contents of two containers. | |
792 //! | |
793 //! <b>Complexity</b>: Constant. | |
794 //! | |
795 //! <b>Throws</b>: If the comparison functor's swap call throws. | |
796 void swap(bstree_impl& other) | |
797 { | |
798 //This can throw | |
799 using std::swap; | |
800 swap(this->comp(), this->comp()); | |
801 //These can't throw | |
802 node_algorithms::swap_tree(this->header_ptr(), node_ptr(other.header_ptr())); | |
803 if(constant_time_size){ | |
804 size_type backup = this->sz_traits().get_size(); | |
805 this->sz_traits().set_size(other.sz_traits().get_size()); | |
806 other.sz_traits().set_size(backup); | |
807 } | |
808 } | |
809 | |
810 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. | |
811 //! Cloner should yield to nodes equivalent to the original nodes. | |
812 //! | |
813 //! <b>Effects</b>: Erases all the elements from *this | |
814 //! calling Disposer::operator()(pointer), clones all the | |
815 //! elements from src calling Cloner::operator()(const_reference ) | |
816 //! and inserts them on *this. Copies the predicate from the source container. | |
817 //! | |
818 //! If cloner throws, all cloned elements are unlinked and disposed | |
819 //! calling Disposer::operator()(pointer). | |
820 //! | |
821 //! <b>Complexity</b>: Linear to erased plus inserted elements. | |
822 //! | |
823 //! <b>Throws</b>: If cloner throws or predicate copy assignment throws. Basic guarantee. | |
824 template <class Cloner, class Disposer> | |
825 void clone_from(const bstree_impl &src, Cloner cloner, Disposer disposer) | |
826 { | |
827 this->clear_and_dispose(disposer); | |
828 if(!src.empty()){ | |
829 detail::exception_disposer<bstree_impl, Disposer> | |
830 rollback(*this, disposer); | |
831 node_algorithms::clone | |
832 (const_node_ptr(src.header_ptr()) | |
833 ,node_ptr(this->header_ptr()) | |
834 ,detail::node_cloner <Cloner, real_value_traits, AlgoType>(cloner, &this->get_real_value_traits()) | |
835 ,detail::node_disposer<Disposer, real_value_traits, AlgoType>(disposer, &this->get_real_value_traits())); | |
836 this->sz_traits().set_size(src.sz_traits().get_size()); | |
837 this->comp() = src.comp(); | |
838 rollback.release(); | |
839 } | |
840 } | |
841 | |
842 //! <b>Requires</b>: value must be an lvalue | |
843 //! | |
844 //! <b>Effects</b>: Inserts value into the container before the upper bound. | |
845 //! | |
846 //! <b>Complexity</b>: Average complexity for insert element is at | |
847 //! most logarithmic. | |
848 //! | |
849 //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. | |
850 //! | |
851 //! <b>Note</b>: Does not affect the validity of iterators and references. | |
852 //! No copy-constructors are called. | |
853 iterator insert_equal(reference value) | |
854 { | |
855 detail::key_nodeptr_comp<value_compare, real_value_traits> | |
856 key_node_comp(this->comp(), &this->get_real_value_traits()); | |
857 node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value)); | |
858 if(safemode_or_autounlink) | |
859 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); | |
860 iterator ret(node_algorithms::insert_equal_upper_bound | |
861 (this->header_ptr(), to_insert, key_node_comp), this->real_value_traits_ptr()); | |
862 this->sz_traits().increment(); | |
863 return ret; | |
864 } | |
865 | |
866 //! <b>Requires</b>: value must be an lvalue, and "hint" must be | |
867 //! a valid iterator. | |
868 //! | |
869 //! <b>Effects</b>: Inserts x into the container, using "hint" as a hint to | |
870 //! where it will be inserted. If "hint" is the upper_bound | |
871 //! the insertion takes constant time (two comparisons in the worst case) | |
872 //! | |
873 //! <b>Complexity</b>: Logarithmic in general, but it is amortized | |
874 //! constant time if t is inserted immediately before hint. | |
875 //! | |
876 //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee. | |
877 //! | |
878 //! <b>Note</b>: Does not affect the validity of iterators and references. | |
879 //! No copy-constructors are called. | |
880 iterator insert_equal(const_iterator hint, reference value) | |
881 { | |
882 detail::key_nodeptr_comp<value_compare, real_value_traits> | |
883 key_node_comp(this->comp(), &this->get_real_value_traits()); | |
884 node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value)); | |
885 if(safemode_or_autounlink) | |
886 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); | |
887 iterator ret(node_algorithms::insert_equal | |
888 (this->header_ptr(), hint.pointed_node(), to_insert, key_node_comp), this->real_value_traits_ptr()); | |
889 this->sz_traits().increment(); | |
890 return ret; | |
891 } | |
892 | |
893 //! <b>Requires</b>: Dereferencing iterator must yield an lvalue | |
894 //! of type value_type. | |
895 //! | |
896 //! <b>Effects</b>: Inserts a each element of a range into the container | |
897 //! before the upper bound of the key of each element. | |
898 //! | |
899 //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the | |
900 //! size of the range. However, it is linear in N if the range is already sorted | |
901 //! by value_comp(). | |
902 //! | |
903 //! <b>Throws</b>: Nothing. | |
904 //! | |
905 //! <b>Note</b>: Does not affect the validity of iterators and references. | |
906 //! No copy-constructors are called. | |
907 template<class Iterator> | |
908 void insert_equal(Iterator b, Iterator e) | |
909 { | |
910 iterator iend(this->end()); | |
911 for (; b != e; ++b) | |
912 this->insert_equal(iend, *b); | |
913 } | |
914 | |
915 //! <b>Requires</b>: value must be an lvalue | |
916 //! | |
917 //! <b>Effects</b>: Inserts value into the container if the value | |
918 //! is not already present. | |
919 //! | |
920 //! <b>Complexity</b>: Average complexity for insert element is at | |
921 //! most logarithmic. | |
922 //! | |
923 //! <b>Throws</b>: Nothing. | |
924 //! | |
925 //! <b>Note</b>: Does not affect the validity of iterators and references. | |
926 //! No copy-constructors are called. | |
927 std::pair<iterator, bool> insert_unique(reference value) | |
928 { | |
929 insert_commit_data commit_data; | |
930 std::pair<iterator, bool> ret = this->insert_unique_check(value, this->comp(), commit_data); | |
931 if(!ret.second) | |
932 return ret; | |
933 return std::pair<iterator, bool> (this->insert_unique_commit(value, commit_data), true); | |
934 } | |
935 | |
936 //! <b>Requires</b>: value must be an lvalue, and "hint" must be | |
937 //! a valid iterator | |
938 //! | |
939 //! <b>Effects</b>: Tries to insert x into the container, using "hint" as a hint | |
940 //! to where it will be inserted. | |
941 //! | |
942 //! <b>Complexity</b>: Logarithmic in general, but it is amortized | |
943 //! constant time (two comparisons in the worst case) | |
944 //! if t is inserted immediately before hint. | |
945 //! | |
946 //! <b>Throws</b>: Nothing. | |
947 //! | |
948 //! <b>Note</b>: Does not affect the validity of iterators and references. | |
949 //! No copy-constructors are called. | |
950 iterator insert_unique(const_iterator hint, reference value) | |
951 { | |
952 insert_commit_data commit_data; | |
953 std::pair<iterator, bool> ret = this->insert_unique_check(hint, value, this->comp(), commit_data); | |
954 if(!ret.second) | |
955 return ret.first; | |
956 return this->insert_unique_commit(value, commit_data); | |
957 } | |
958 | |
959 //! <b>Requires</b>: Dereferencing iterator must yield an lvalue | |
960 //! of type value_type. | |
961 //! | |
962 //! <b>Effects</b>: Tries to insert each element of a range into the container. | |
963 //! | |
964 //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the | |
965 //! size of the range. However, it is linear in N if the range is already sorted | |
966 //! by value_comp(). | |
967 //! | |
968 //! <b>Throws</b>: Nothing. | |
969 //! | |
970 //! <b>Note</b>: Does not affect the validity of iterators and references. | |
971 //! No copy-constructors are called. | |
972 template<class Iterator> | |
973 void insert_unique(Iterator b, Iterator e) | |
974 { | |
975 if(this->empty()){ | |
976 iterator iend(this->end()); | |
977 for (; b != e; ++b) | |
978 this->insert_unique(iend, *b); | |
979 } | |
980 else{ | |
981 for (; b != e; ++b) | |
982 this->insert_unique(*b); | |
983 } | |
984 } | |
985 | |
986 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED | |
987 | |
988 //! <b>Requires</b>: key_value_comp must be a comparison function that induces | |
989 //! the same strict weak ordering as value_compare. The difference is that | |
990 //! key_value_comp compares an arbitrary key with the contained values. | |
991 //! | |
992 //! <b>Effects</b>: Checks if a value can be inserted in the container, using | |
993 //! a user provided key instead of the value itself. | |
994 //! | |
995 //! <b>Returns</b>: If there is an equivalent value | |
996 //! returns a pair containing an iterator to the already present value | |
997 //! and false. If the value can be inserted returns true in the returned | |
998 //! pair boolean and fills "commit_data" that is meant to be used with | |
999 //! the "insert_commit" function. | |
1000 //! | |
1001 //! <b>Complexity</b>: Average complexity is at most logarithmic. | |
1002 //! | |
1003 //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee. | |
1004 //! | |
1005 //! <b>Notes</b>: This function is used to improve performance when constructing | |
1006 //! a value_type is expensive: if there is an equivalent value | |
1007 //! the constructed object must be discarded. Many times, the part of the | |
1008 //! node that is used to impose the order is much cheaper to construct | |
1009 //! than the value_type and this function offers the possibility to use that | |
1010 //! part to check if the insertion will be successful. | |
1011 //! | |
1012 //! If the check is successful, the user can construct the value_type and use | |
1013 //! "insert_commit" to insert the object in constant-time. This gives a total | |
1014 //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). | |
1015 //! | |
1016 //! "commit_data" remains valid for a subsequent "insert_commit" only if no more | |
1017 //! objects are inserted or erased from the container. | |
1018 template<class KeyType, class KeyValueCompare> | |
1019 std::pair<iterator, bool> insert_unique_check | |
1020 (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data); | |
1021 | |
1022 //! <b>Requires</b>: key_value_comp must be a comparison function that induces | |
1023 //! the same strict weak ordering as value_compare. The difference is that | |
1024 //! key_value_comp compares an arbitrary key with the contained values. | |
1025 //! | |
1026 //! <b>Effects</b>: Checks if a value can be inserted in the container, using | |
1027 //! a user provided key instead of the value itself, using "hint" | |
1028 //! as a hint to where it will be inserted. | |
1029 //! | |
1030 //! <b>Returns</b>: If there is an equivalent value | |
1031 //! returns a pair containing an iterator to the already present value | |
1032 //! and false. If the value can be inserted returns true in the returned | |
1033 //! pair boolean and fills "commit_data" that is meant to be used with | |
1034 //! the "insert_commit" function. | |
1035 //! | |
1036 //! <b>Complexity</b>: Logarithmic in general, but it's amortized | |
1037 //! constant time if t is inserted immediately before hint. | |
1038 //! | |
1039 //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee. | |
1040 //! | |
1041 //! <b>Notes</b>: This function is used to improve performance when constructing | |
1042 //! a value_type is expensive: if there is an equivalent value | |
1043 //! the constructed object must be discarded. Many times, the part of the | |
1044 //! constructing that is used to impose the order is much cheaper to construct | |
1045 //! than the value_type and this function offers the possibility to use that key | |
1046 //! to check if the insertion will be successful. | |
1047 //! | |
1048 //! If the check is successful, the user can construct the value_type and use | |
1049 //! "insert_commit" to insert the object in constant-time. This can give a total | |
1050 //! constant-time complexity to the insertion: check(O(1)) + commit(O(1)). | |
1051 //! | |
1052 //! "commit_data" remains valid for a subsequent "insert_commit" only if no more | |
1053 //! objects are inserted or erased from the container. | |
1054 template<class KeyType, class KeyValueCompare> | |
1055 std::pair<iterator, bool> insert_unique_check | |
1056 (const_iterator hint, const KeyType &key | |
1057 ,KeyValueCompare key_value_comp, insert_commit_data &commit_data); | |
1058 | |
1059 #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED | |
1060 | |
1061 //! <b>Requires</b>: value must be an lvalue of type value_type. commit_data | |
1062 //! must have been obtained from a previous call to "insert_check". | |
1063 //! No objects should have been inserted or erased from the container between | |
1064 //! the "insert_check" that filled "commit_data" and the call to "insert_commit". | |
1065 //! | |
1066 //! <b>Effects</b>: Inserts the value in the container using the information obtained | |
1067 //! from the "commit_data" that a previous "insert_check" filled. | |
1068 //! | |
1069 //! <b>Returns</b>: An iterator to the newly inserted object. | |
1070 //! | |
1071 //! <b>Complexity</b>: Constant time. | |
1072 //! | |
1073 //! <b>Throws</b>: Nothing. | |
1074 //! | |
1075 //! <b>Notes</b>: This function has only sense if a "insert_check" has been | |
1076 //! previously executed to fill "commit_data". No value should be inserted or | |
1077 //! erased between the "insert_check" and "insert_commit" calls. | |
1078 iterator insert_unique_commit(reference value, const insert_commit_data &commit_data) | |
1079 { | |
1080 node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value)); | |
1081 if(safemode_or_autounlink) | |
1082 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); | |
1083 node_algorithms::insert_unique_commit | |
1084 (this->header_ptr(), to_insert, commit_data); | |
1085 this->sz_traits().increment(); | |
1086 return iterator(to_insert, this->real_value_traits_ptr()); | |
1087 } | |
1088 | |
1089 //! <b>Requires</b>: value must be an lvalue, "pos" must be | |
1090 //! a valid iterator (or end) and must be the succesor of value | |
1091 //! once inserted according to the predicate | |
1092 //! | |
1093 //! <b>Effects</b>: Inserts x into the container before "pos". | |
1094 //! | |
1095 //! <b>Complexity</b>: Constant time. | |
1096 //! | |
1097 //! <b>Throws</b>: Nothing. | |
1098 //! | |
1099 //! <b>Note</b>: This function does not check preconditions so if "pos" is not | |
1100 //! the successor of "value" container ordering invariant will be broken. | |
1101 //! This is a low-level function to be used only for performance reasons | |
1102 //! by advanced users. | |
1103 iterator insert_before(const_iterator pos, reference value) | |
1104 { | |
1105 node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value)); | |
1106 if(safemode_or_autounlink) | |
1107 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); | |
1108 this->sz_traits().increment(); | |
1109 return iterator(node_algorithms::insert_before | |
1110 (this->header_ptr(), pos.pointed_node(), to_insert), this->real_value_traits_ptr()); | |
1111 } | |
1112 | |
1113 //! <b>Requires</b>: value must be an lvalue, and it must be no less | |
1114 //! than the greatest inserted key | |
1115 //! | |
1116 //! <b>Effects</b>: Inserts x into the container in the last position. | |
1117 //! | |
1118 //! <b>Complexity</b>: Constant time. | |
1119 //! | |
1120 //! <b>Throws</b>: Nothing. | |
1121 //! | |
1122 //! <b>Note</b>: This function does not check preconditions so if value is | |
1123 //! less than the greatest inserted key container ordering invariant will be broken. | |
1124 //! This function is slightly more efficient than using "insert_before". | |
1125 //! This is a low-level function to be used only for performance reasons | |
1126 //! by advanced users. | |
1127 void push_back(reference value) | |
1128 { | |
1129 node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value)); | |
1130 if(safemode_or_autounlink) | |
1131 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); | |
1132 this->sz_traits().increment(); | |
1133 node_algorithms::push_back(this->header_ptr(), to_insert); | |
1134 } | |
1135 | |
1136 //! <b>Requires</b>: value must be an lvalue, and it must be no greater | |
1137 //! than the minimum inserted key | |
1138 //! | |
1139 //! <b>Effects</b>: Inserts x into the container in the first position. | |
1140 //! | |
1141 //! <b>Complexity</b>: Constant time. | |
1142 //! | |
1143 //! <b>Throws</b>: Nothing. | |
1144 //! | |
1145 //! <b>Note</b>: This function does not check preconditions so if value is | |
1146 //! greater than the minimum inserted key container ordering invariant will be broken. | |
1147 //! This function is slightly more efficient than using "insert_before". | |
1148 //! This is a low-level function to be used only for performance reasons | |
1149 //! by advanced users. | |
1150 void push_front(reference value) | |
1151 { | |
1152 node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value)); | |
1153 if(safemode_or_autounlink) | |
1154 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); | |
1155 this->sz_traits().increment(); | |
1156 node_algorithms::push_front(this->header_ptr(), to_insert); | |
1157 } | |
1158 | |
1159 //! <b>Effects</b>: Erases the element pointed to by pos. | |
1160 //! | |
1161 //! <b>Complexity</b>: Average complexity for erase element is constant time. | |
1162 //! | |
1163 //! <b>Throws</b>: Nothing. | |
1164 //! | |
1165 //! <b>Note</b>: Invalidates the iterators (but not the references) | |
1166 //! to the erased elements. No destructors are called. | |
1167 iterator erase(const_iterator i) | |
1168 { | |
1169 const_iterator ret(i); | |
1170 ++ret; | |
1171 node_ptr to_erase(i.pointed_node()); | |
1172 if(safemode_or_autounlink) | |
1173 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!node_algorithms::unique(to_erase)); | |
1174 node_algorithms::erase(this->header_ptr(), to_erase); | |
1175 this->sz_traits().decrement(); | |
1176 if(safemode_or_autounlink) | |
1177 node_algorithms::init(to_erase); | |
1178 return ret.unconst(); | |
1179 } | |
1180 | |
1181 //! <b>Effects</b>: Erases the range pointed to by b end e. | |
1182 //! | |
1183 //! <b>Complexity</b>: Average complexity for erase range is at most | |
1184 //! O(log(size() + N)), where N is the number of elements in the range. | |
1185 //! | |
1186 //! <b>Throws</b>: Nothing. | |
1187 //! | |
1188 //! <b>Note</b>: Invalidates the iterators (but not the references) | |
1189 //! to the erased elements. No destructors are called. | |
1190 iterator erase(const_iterator b, const_iterator e) | |
1191 { size_type n; return this->private_erase(b, e, n); } | |
1192 | |
1193 //! <b>Effects</b>: Erases all the elements with the given value. | |
1194 //! | |
1195 //! <b>Returns</b>: The number of erased elements. | |
1196 //! | |
1197 //! <b>Complexity</b>: O(log(size() + N). | |
1198 //! | |
1199 //! <b>Throws</b>: Nothing. | |
1200 //! | |
1201 //! <b>Note</b>: Invalidates the iterators (but not the references) | |
1202 //! to the erased elements. No destructors are called. | |
1203 size_type erase(const_reference value) | |
1204 { return this->erase(value, this->comp()); } | |
1205 | |
1206 //! <b>Effects</b>: Erases all the elements with the given key. | |
1207 //! according to the comparison functor "comp". | |
1208 //! | |
1209 //! <b>Returns</b>: The number of erased elements. | |
1210 //! | |
1211 //! <b>Complexity</b>: O(log(size() + N). | |
1212 //! | |
1213 //! <b>Throws</b>: Nothing. | |
1214 //! | |
1215 //! <b>Note</b>: Invalidates the iterators (but not the references) | |
1216 //! to the erased elements. No destructors are called. | |
1217 template<class KeyType, class KeyValueCompare> | |
1218 size_type erase(const KeyType& key, KeyValueCompare comp | |
1219 /// @cond | |
1220 , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 | |
1221 /// @endcond | |
1222 ) | |
1223 { | |
1224 std::pair<iterator,iterator> p = this->equal_range(key, comp); | |
1225 size_type n; | |
1226 this->private_erase(p.first, p.second, n); | |
1227 return n; | |
1228 } | |
1229 | |
1230 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. | |
1231 //! | |
1232 //! <b>Effects</b>: Erases the element pointed to by pos. | |
1233 //! Disposer::operator()(pointer) is called for the removed element. | |
1234 //! | |
1235 //! <b>Complexity</b>: Average complexity for erase element is constant time. | |
1236 //! | |
1237 //! <b>Throws</b>: Nothing. | |
1238 //! | |
1239 //! <b>Note</b>: Invalidates the iterators | |
1240 //! to the erased elements. | |
1241 template<class Disposer> | |
1242 iterator erase_and_dispose(const_iterator i, Disposer disposer) | |
1243 { | |
1244 node_ptr to_erase(i.pointed_node()); | |
1245 iterator ret(this->erase(i)); | |
1246 disposer(this->get_real_value_traits().to_value_ptr(to_erase)); | |
1247 return ret; | |
1248 } | |
1249 | |
1250 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
1251 template<class Disposer> | |
1252 iterator erase_and_dispose(iterator i, Disposer disposer) | |
1253 { return this->erase_and_dispose(const_iterator(i), disposer); } | |
1254 #endif | |
1255 | |
1256 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. | |
1257 //! | |
1258 //! <b>Effects</b>: Erases all the elements with the given value. | |
1259 //! Disposer::operator()(pointer) is called for the removed elements. | |
1260 //! | |
1261 //! <b>Returns</b>: The number of erased elements. | |
1262 //! | |
1263 //! <b>Complexity</b>: O(log(size() + N). | |
1264 //! | |
1265 //! <b>Throws</b>: Nothing. | |
1266 //! | |
1267 //! <b>Note</b>: Invalidates the iterators (but not the references) | |
1268 //! to the erased elements. No destructors are called. | |
1269 template<class Disposer> | |
1270 size_type erase_and_dispose(const_reference value, Disposer disposer) | |
1271 { | |
1272 std::pair<iterator,iterator> p = this->equal_range(value); | |
1273 size_type n; | |
1274 this->private_erase(p.first, p.second, n, disposer); | |
1275 return n; | |
1276 } | |
1277 | |
1278 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. | |
1279 //! | |
1280 //! <b>Effects</b>: Erases the range pointed to by b end e. | |
1281 //! Disposer::operator()(pointer) is called for the removed elements. | |
1282 //! | |
1283 //! <b>Complexity</b>: Average complexity for erase range is at most | |
1284 //! O(log(size() + N)), where N is the number of elements in the range. | |
1285 //! | |
1286 //! <b>Throws</b>: Nothing. | |
1287 //! | |
1288 //! <b>Note</b>: Invalidates the iterators | |
1289 //! to the erased elements. | |
1290 template<class Disposer> | |
1291 iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) | |
1292 { size_type n; return this->private_erase(b, e, n, disposer); } | |
1293 | |
1294 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. | |
1295 //! | |
1296 //! <b>Effects</b>: Erases all the elements with the given key. | |
1297 //! according to the comparison functor "comp". | |
1298 //! Disposer::operator()(pointer) is called for the removed elements. | |
1299 //! | |
1300 //! <b>Returns</b>: The number of erased elements. | |
1301 //! | |
1302 //! <b>Complexity</b>: O(log(size() + N). | |
1303 //! | |
1304 //! <b>Throws</b>: Nothing. | |
1305 //! | |
1306 //! <b>Note</b>: Invalidates the iterators | |
1307 //! to the erased elements. | |
1308 template<class KeyType, class KeyValueCompare, class Disposer> | |
1309 size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer | |
1310 /// @cond | |
1311 , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0 | |
1312 /// @endcond | |
1313 ) | |
1314 { | |
1315 std::pair<iterator,iterator> p = this->equal_range(key, comp); | |
1316 size_type n; | |
1317 this->private_erase(p.first, p.second, n, disposer); | |
1318 return n; | |
1319 } | |
1320 | |
1321 //! <b>Effects</b>: Erases all of the elements. | |
1322 //! | |
1323 //! <b>Complexity</b>: Linear to the number of elements on the container. | |
1324 //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. | |
1325 //! | |
1326 //! <b>Throws</b>: Nothing. | |
1327 //! | |
1328 //! <b>Note</b>: Invalidates the iterators (but not the references) | |
1329 //! to the erased elements. No destructors are called. | |
1330 void clear() | |
1331 { | |
1332 if(safemode_or_autounlink){ | |
1333 this->clear_and_dispose(detail::null_disposer()); | |
1334 } | |
1335 else{ | |
1336 node_algorithms::init_header(this->header_ptr()); | |
1337 this->sz_traits().set_size(0); | |
1338 } | |
1339 } | |
1340 | |
1341 //! <b>Effects</b>: Erases all of the elements calling disposer(p) for | |
1342 //! each node to be erased. | |
1343 //! <b>Complexity</b>: Average complexity for is at most O(log(size() + N)), | |
1344 //! where N is the number of elements in the container. | |
1345 //! | |
1346 //! <b>Throws</b>: Nothing. | |
1347 //! | |
1348 //! <b>Note</b>: Invalidates the iterators (but not the references) | |
1349 //! to the erased elements. Calls N times to disposer functor. | |
1350 template<class Disposer> | |
1351 void clear_and_dispose(Disposer disposer) | |
1352 { | |
1353 node_algorithms::clear_and_dispose(this->header_ptr() | |
1354 , detail::node_disposer<Disposer, real_value_traits, AlgoType>(disposer, &this->get_real_value_traits())); | |
1355 node_algorithms::init_header(this->header_ptr()); | |
1356 this->sz_traits().set_size(0); | |
1357 } | |
1358 | |
1359 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
1360 | |
1361 //! <b>Effects</b>: Returns the number of contained elements with the given value | |
1362 //! | |
1363 //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal | |
1364 //! to number of objects with the given value. | |
1365 //! | |
1366 //! <b>Throws</b>: Nothing. | |
1367 size_type count(const_reference value) const; | |
1368 | |
1369 //! <b>Effects</b>: Returns the number of contained elements with the given key | |
1370 //! | |
1371 //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal | |
1372 //! to number of objects with the given key. | |
1373 //! | |
1374 //! <b>Throws</b>: Nothing. | |
1375 template<class KeyType, class KeyValueCompare> | |
1376 size_type count(const KeyType &key, KeyValueCompare comp) const; | |
1377 | |
1378 //! <b>Effects</b>: Returns an iterator to the first element whose | |
1379 //! key is not less than k or end() if that element does not exist. | |
1380 //! | |
1381 //! <b>Complexity</b>: Logarithmic. | |
1382 //! | |
1383 //! <b>Throws</b>: Nothing. | |
1384 iterator lower_bound(const_reference value); | |
1385 | |
1386 //! <b>Effects</b>: Returns an iterator to the first element whose | |
1387 //! key is not less than k or end() if that element does not exist. | |
1388 //! | |
1389 //! <b>Complexity</b>: Logarithmic. | |
1390 //! | |
1391 //! <b>Throws</b>: Nothing. | |
1392 const_iterator lower_bound(const_reference value) const; | |
1393 | |
1394 //! <b>Effects</b>: Returns an iterator to the first element whose | |
1395 //! key is not less than k or end() if that element does not exist. | |
1396 //! | |
1397 //! <b>Complexity</b>: Logarithmic. | |
1398 //! | |
1399 //! <b>Throws</b>: Nothing. | |
1400 template<class KeyType, class KeyValueCompare> | |
1401 iterator lower_bound(const KeyType &key, KeyValueCompare comp); | |
1402 | |
1403 //! <b>Effects</b>: Returns a const iterator to the first element whose | |
1404 //! key is not less than k or end() if that element does not exist. | |
1405 //! | |
1406 //! <b>Complexity</b>: Logarithmic. | |
1407 //! | |
1408 //! <b>Throws</b>: Nothing. | |
1409 template<class KeyType, class KeyValueCompare> | |
1410 const_iterator lower_bound(const KeyType &key, KeyValueCompare comp) const; | |
1411 | |
1412 //! <b>Effects</b>: Returns an iterator to the first element whose | |
1413 //! key is greater than k or end() if that element does not exist. | |
1414 //! | |
1415 //! <b>Complexity</b>: Logarithmic. | |
1416 //! | |
1417 //! <b>Throws</b>: Nothing. | |
1418 iterator upper_bound(const_reference value); | |
1419 | |
1420 //! <b>Effects</b>: Returns an iterator to the first element whose | |
1421 //! key is greater than k according to comp or end() if that element | |
1422 //! does not exist. | |
1423 //! | |
1424 //! <b>Complexity</b>: Logarithmic. | |
1425 //! | |
1426 //! <b>Throws</b>: Nothing. | |
1427 template<class KeyType, class KeyValueCompare> | |
1428 iterator upper_bound(const KeyType &key, KeyValueCompare comp); | |
1429 | |
1430 //! <b>Effects</b>: Returns an iterator to the first element whose | |
1431 //! key is greater than k or end() if that element does not exist. | |
1432 //! | |
1433 //! <b>Complexity</b>: Logarithmic. | |
1434 //! | |
1435 //! <b>Throws</b>: Nothing. | |
1436 const_iterator upper_bound(const_reference value) const; | |
1437 | |
1438 //! <b>Effects</b>: Returns an iterator to the first element whose | |
1439 //! key is greater than k according to comp or end() if that element | |
1440 //! does not exist. | |
1441 //! | |
1442 //! <b>Complexity</b>: Logarithmic. | |
1443 //! | |
1444 //! <b>Throws</b>: Nothing. | |
1445 template<class KeyType, class KeyValueCompare> | |
1446 const_iterator upper_bound(const KeyType &key, KeyValueCompare comp) const; | |
1447 | |
1448 //! <b>Effects</b>: Finds an iterator to the first element whose key is | |
1449 //! k or end() if that element does not exist. | |
1450 //! | |
1451 //! <b>Complexity</b>: Logarithmic. | |
1452 //! | |
1453 //! <b>Throws</b>: Nothing. | |
1454 iterator find(const_reference value); | |
1455 | |
1456 //! <b>Effects</b>: Finds an iterator to the first element whose key is | |
1457 //! k or end() if that element does not exist. | |
1458 //! | |
1459 //! <b>Complexity</b>: Logarithmic. | |
1460 //! | |
1461 //! <b>Throws</b>: Nothing. | |
1462 template<class KeyType, class KeyValueCompare> | |
1463 iterator find(const KeyType &key, KeyValueCompare comp); | |
1464 | |
1465 //! <b>Effects</b>: Finds a const_iterator to the first element whose key is | |
1466 //! k or end() if that element does not exist. | |
1467 //! | |
1468 //! <b>Complexity</b>: Logarithmic. | |
1469 //! | |
1470 //! <b>Throws</b>: Nothing. | |
1471 const_iterator find(const_reference value) const; | |
1472 | |
1473 //! <b>Effects</b>: Finds a const_iterator to the first element whose key is | |
1474 //! k or end() if that element does not exist. | |
1475 //! | |
1476 //! <b>Complexity</b>: Logarithmic. | |
1477 //! | |
1478 //! <b>Throws</b>: Nothing. | |
1479 template<class KeyType, class KeyValueCompare> | |
1480 const_iterator find(const KeyType &key, KeyValueCompare comp) const; | |
1481 | |
1482 //! <b>Effects</b>: Finds a range containing all elements whose key is k or | |
1483 //! an empty range that indicates the position where those elements would be | |
1484 //! if they there is no elements with key k. | |
1485 //! | |
1486 //! <b>Complexity</b>: Logarithmic. | |
1487 //! | |
1488 //! <b>Throws</b>: Nothing. | |
1489 std::pair<iterator,iterator> equal_range(const_reference value); | |
1490 | |
1491 //! <b>Effects</b>: Finds a range containing all elements whose key is k or | |
1492 //! an empty range that indicates the position where those elements would be | |
1493 //! if they there is no elements with key k. | |
1494 //! | |
1495 //! <b>Complexity</b>: Logarithmic. | |
1496 //! | |
1497 //! <b>Throws</b>: Nothing. | |
1498 template<class KeyType, class KeyValueCompare> | |
1499 std::pair<iterator,iterator> equal_range(const KeyType &key, KeyValueCompare comp); | |
1500 | |
1501 //! <b>Effects</b>: Finds a range containing all elements whose key is k or | |
1502 //! an empty range that indicates the position where those elements would be | |
1503 //! if they there is no elements with key k. | |
1504 //! | |
1505 //! <b>Complexity</b>: Logarithmic. | |
1506 //! | |
1507 //! <b>Throws</b>: Nothing. | |
1508 std::pair<const_iterator, const_iterator> | |
1509 equal_range(const_reference value) const; | |
1510 | |
1511 //! <b>Effects</b>: Finds a range containing all elements whose key is k or | |
1512 //! an empty range that indicates the position where those elements would be | |
1513 //! if they there is no elements with key k. | |
1514 //! | |
1515 //! <b>Complexity</b>: Logarithmic. | |
1516 //! | |
1517 //! <b>Throws</b>: Nothing. | |
1518 template<class KeyType, class KeyValueCompare> | |
1519 std::pair<const_iterator, const_iterator> | |
1520 equal_range(const KeyType &key, KeyValueCompare comp) const; | |
1521 | |
1522 //! <b>Requires</b>: 'lower_value' must not be greater than 'upper_value'. If | |
1523 //! 'lower_value' == 'upper_value', ('left_closed' || 'right_closed') must be false. | |
1524 //! | |
1525 //! <b>Effects</b>: Returns an a pair with the following criteria: | |
1526 //! | |
1527 //! first = lower_bound(lower_key) if left_closed, upper_bound(lower_key) otherwise | |
1528 //! | |
1529 //! second = upper_bound(upper_key) if right_closed, lower_bound(upper_key) otherwise | |
1530 //! | |
1531 //! <b>Complexity</b>: Logarithmic. | |
1532 //! | |
1533 //! <b>Throws</b>: If the predicate throws. | |
1534 //! | |
1535 //! <b>Note</b>: This function can be more efficient than calling upper_bound | |
1536 //! and lower_bound for lower_value and upper_value. | |
1537 //! | |
1538 //! <b>Note</b>: Experimental function, the interface might change in future releases. | |
1539 std::pair<iterator,iterator> bounded_range | |
1540 (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed); | |
1541 | |
1542 //! <b>Requires</b>: KeyValueCompare is a function object that induces a strict weak | |
1543 //! ordering compatible with the strict weak ordering used to create the | |
1544 //! the container. | |
1545 //! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If | |
1546 //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false. | |
1547 //! | |
1548 //! <b>Effects</b>: Returns an a pair with the following criteria: | |
1549 //! | |
1550 //! first = lower_bound(lower_key, comp) if left_closed, upper_bound(lower_key, comp) otherwise | |
1551 //! | |
1552 //! second = upper_bound(upper_key, comp) if right_closed, lower_bound(upper_key, comp) otherwise | |
1553 //! | |
1554 //! <b>Complexity</b>: Logarithmic. | |
1555 //! | |
1556 //! <b>Throws</b>: If "comp" throws. | |
1557 //! | |
1558 //! <b>Note</b>: This function can be more efficient than calling upper_bound | |
1559 //! and lower_bound for lower_key and upper_key. | |
1560 //! | |
1561 //! <b>Note</b>: Experimental function, the interface might change in future releases. | |
1562 template<class KeyType, class KeyValueCompare> | |
1563 std::pair<iterator,iterator> bounded_range | |
1564 (const KeyType &lower_key, const KeyType &upper_key, KeyValueCompare comp, bool left_closed, bool right_closed); | |
1565 | |
1566 //! <b>Requires</b>: 'lower_value' must not be greater than 'upper_value'. If | |
1567 //! 'lower_value' == 'upper_value', ('left_closed' || 'right_closed') must be false. | |
1568 //! | |
1569 //! <b>Effects</b>: Returns an a pair with the following criteria: | |
1570 //! | |
1571 //! first = lower_bound(lower_key) if left_closed, upper_bound(lower_key) otherwise | |
1572 //! | |
1573 //! second = upper_bound(upper_key) if right_closed, lower_bound(upper_key) otherwise | |
1574 //! | |
1575 //! <b>Complexity</b>: Logarithmic. | |
1576 //! | |
1577 //! <b>Throws</b>: If the predicate throws. | |
1578 //! | |
1579 //! <b>Note</b>: This function can be more efficient than calling upper_bound | |
1580 //! and lower_bound for lower_value and upper_value. | |
1581 //! | |
1582 //! <b>Note</b>: Experimental function, the interface might change in future releases. | |
1583 std::pair<const_iterator,const_iterator> bounded_range | |
1584 (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) const; | |
1585 | |
1586 //! <b>Requires</b>: KeyValueCompare is a function object that induces a strict weak | |
1587 //! ordering compatible with the strict weak ordering used to create the | |
1588 //! the container. | |
1589 //! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If | |
1590 //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false. | |
1591 //! | |
1592 //! <b>Effects</b>: Returns an a pair with the following criteria: | |
1593 //! | |
1594 //! first = lower_bound(lower_key, comp) if left_closed, upper_bound(lower_key, comp) otherwise | |
1595 //! | |
1596 //! second = upper_bound(upper_key, comp) if right_closed, lower_bound(upper_key, comp) otherwise | |
1597 //! | |
1598 //! <b>Complexity</b>: Logarithmic. | |
1599 //! | |
1600 //! <b>Throws</b>: If "comp" throws. | |
1601 //! | |
1602 //! <b>Note</b>: This function can be more efficient than calling upper_bound | |
1603 //! and lower_bound for lower_key and upper_key. | |
1604 //! | |
1605 //! <b>Note</b>: Experimental function, the interface might change in future releases. | |
1606 template<class KeyType, class KeyValueCompare> | |
1607 std::pair<const_iterator,const_iterator> bounded_range | |
1608 (const KeyType &lower_key, const KeyType &upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) const; | |
1609 | |
1610 //! <b>Requires</b>: value must be an lvalue and shall be in a set of | |
1611 //! appropriate type. Otherwise the behavior is undefined. | |
1612 //! | |
1613 //! <b>Effects</b>: Returns: a valid iterator i belonging to the set | |
1614 //! that points to the value | |
1615 //! | |
1616 //! <b>Complexity</b>: Constant. | |
1617 //! | |
1618 //! <b>Throws</b>: Nothing. | |
1619 //! | |
1620 //! <b>Note</b>: This static function is available only if the <i>value traits</i> | |
1621 //! is stateless. | |
1622 static iterator s_iterator_to(reference value); | |
1623 | |
1624 //! <b>Requires</b>: value must be an lvalue and shall be in a set of | |
1625 //! appropriate type. Otherwise the behavior is undefined. | |
1626 //! | |
1627 //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the | |
1628 //! set that points to the value | |
1629 //! | |
1630 //! <b>Complexity</b>: Constant. | |
1631 //! | |
1632 //! <b>Throws</b>: Nothing. | |
1633 //! | |
1634 //! <b>Note</b>: This static function is available only if the <i>value traits</i> | |
1635 //! is stateless. | |
1636 static const_iterator s_iterator_to(const_reference value); | |
1637 | |
1638 //! <b>Requires</b>: value must be an lvalue and shall be in a set of | |
1639 //! appropriate type. Otherwise the behavior is undefined. | |
1640 //! | |
1641 //! <b>Effects</b>: Returns: a valid iterator i belonging to the set | |
1642 //! that points to the value | |
1643 //! | |
1644 //! <b>Complexity</b>: Constant. | |
1645 //! | |
1646 //! <b>Throws</b>: Nothing. | |
1647 iterator iterator_to(reference value); | |
1648 | |
1649 //! <b>Requires</b>: value must be an lvalue and shall be in a set of | |
1650 //! appropriate type. Otherwise the behavior is undefined. | |
1651 //! | |
1652 //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the | |
1653 //! set that points to the value | |
1654 //! | |
1655 //! <b>Complexity</b>: Constant. | |
1656 //! | |
1657 //! <b>Throws</b>: Nothing. | |
1658 const_iterator iterator_to(const_reference value) const; | |
1659 | |
1660 //! <b>Requires</b>: value shall not be in a container. | |
1661 //! | |
1662 //! <b>Effects</b>: init_node puts the hook of a value in a well-known default | |
1663 //! state. | |
1664 //! | |
1665 //! <b>Throws</b>: Nothing. | |
1666 //! | |
1667 //! <b>Complexity</b>: Constant time. | |
1668 //! | |
1669 //! <b>Note</b>: This function puts the hook in the well-known default state | |
1670 //! used by auto_unlink and safe hooks. | |
1671 static void init_node(reference value); | |
1672 | |
1673 #endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
1674 | |
1675 //! <b>Effects</b>: Unlinks the leftmost node from the container. | |
1676 //! | |
1677 //! <b>Complexity</b>: Average complexity is constant time. | |
1678 //! | |
1679 //! <b>Throws</b>: Nothing. | |
1680 //! | |
1681 //! <b>Notes</b>: This function breaks the container and the container can | |
1682 //! only be used for more unlink_leftmost_without_rebalance calls. | |
1683 //! This function is normally used to achieve a step by step | |
1684 //! controlled destruction of the container. | |
1685 pointer unlink_leftmost_without_rebalance() | |
1686 { | |
1687 node_ptr to_be_disposed(node_algorithms::unlink_leftmost_without_rebalance | |
1688 (this->header_ptr())); | |
1689 if(!to_be_disposed) | |
1690 return 0; | |
1691 this->sz_traits().decrement(); | |
1692 if(safemode_or_autounlink)//If this is commented does not work with normal_link | |
1693 node_algorithms::init(to_be_disposed); | |
1694 return this->get_real_value_traits().to_value_ptr(to_be_disposed); | |
1695 } | |
1696 | |
1697 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
1698 | |
1699 //! <b>Requires</b>: replace_this must be a valid iterator of *this | |
1700 //! and with_this must not be inserted in any container. | |
1701 //! | |
1702 //! <b>Effects</b>: Replaces replace_this in its position in the | |
1703 //! container with with_this. The container does not need to be rebalanced. | |
1704 //! | |
1705 //! <b>Complexity</b>: Constant. | |
1706 //! | |
1707 //! <b>Throws</b>: Nothing. | |
1708 //! | |
1709 //! <b>Note</b>: This function will break container ordering invariants if | |
1710 //! with_this is not equivalent to *replace_this according to the | |
1711 //! ordering rules. This function is faster than erasing and inserting | |
1712 //! the node, since no rebalancing or comparison is needed. | |
1713 void replace_node(iterator replace_this, reference with_this); | |
1714 | |
1715 //! <b>Effects</b>: Rebalances the tree. | |
1716 //! | |
1717 //! <b>Throws</b>: Nothing. | |
1718 //! | |
1719 //! <b>Complexity</b>: Linear. | |
1720 void rebalance(); | |
1721 | |
1722 //! <b>Requires</b>: old_root is a node of a tree. | |
1723 //! | |
1724 //! <b>Effects</b>: Rebalances the subtree rooted at old_root. | |
1725 //! | |
1726 //! <b>Returns</b>: The new root of the subtree. | |
1727 //! | |
1728 //! <b>Throws</b>: Nothing. | |
1729 //! | |
1730 //! <b>Complexity</b>: Linear to the elements in the subtree. | |
1731 iterator rebalance_subtree(iterator root); | |
1732 | |
1733 #endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
1734 | |
1735 //! <b>Effects</b>: removes "value" from the container. | |
1736 //! | |
1737 //! <b>Throws</b>: Nothing. | |
1738 //! | |
1739 //! <b>Complexity</b>: Logarithmic time. | |
1740 //! | |
1741 //! <b>Note</b>: This static function is only usable with non-constant | |
1742 //! time size containers that have stateless comparison functors. | |
1743 //! | |
1744 //! If the user calls | |
1745 //! this function with a constant time size container or stateful comparison | |
1746 //! functor a compilation error will be issued. | |
1747 static void remove_node(reference value) | |
1748 { | |
1749 BOOST_STATIC_ASSERT((!constant_time_size)); | |
1750 node_ptr to_remove(value_traits::to_node_ptr(value)); | |
1751 node_algorithms::unlink(to_remove); | |
1752 if(safemode_or_autounlink) | |
1753 node_algorithms::init(to_remove); | |
1754 } | |
1755 | |
1756 /// @cond | |
1757 private: | |
1758 template<class Disposer> | |
1759 iterator private_erase(const_iterator b, const_iterator e, size_type &n, Disposer disposer) | |
1760 { | |
1761 for(n = 0; b != e; ++n) | |
1762 this->erase_and_dispose(b++, disposer); | |
1763 return b.unconst(); | |
1764 } | |
1765 | |
1766 iterator private_erase(const_iterator b, const_iterator e, size_type &n) | |
1767 { | |
1768 for(n = 0; b != e; ++n) | |
1769 this->erase(b++); | |
1770 return b.unconst(); | |
1771 } | |
1772 /// @endcond | |
1773 | |
1774 private: | |
1775 static bstree_impl &priv_container_from_end_iterator(const const_iterator &end_iterator) | |
1776 { | |
1777 return *static_cast<bstree_impl*> | |
1778 (boost::intrusive::detail::to_raw_pointer(end_iterator.pointed_node())); | |
1779 } | |
1780 }; | |
1781 | |
1782 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
1783 template<class T, class ...Options> | |
1784 #else | |
1785 template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType> | |
1786 #endif | |
1787 inline bool operator< | |
1788 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
1789 (const bstree_impl<T, Options...> &x, const bstree_impl<T, Options...> &y) | |
1790 #else | |
1791 ( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &x | |
1792 , const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &y) | |
1793 #endif | |
1794 { return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } | |
1795 | |
1796 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
1797 template<class T, class ...Options> | |
1798 #else | |
1799 template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType> | |
1800 #endif | |
1801 bool operator== | |
1802 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
1803 (const bstree_impl<T, Options...> &x, const bstree_impl<T, Options...> &y) | |
1804 #else | |
1805 ( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &x | |
1806 , const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &y) | |
1807 #endif | |
1808 { | |
1809 typedef bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> tree_type; | |
1810 typedef typename tree_type::const_iterator const_iterator; | |
1811 | |
1812 if(tree_type::constant_time_size && x.size() != y.size()){ | |
1813 return false; | |
1814 } | |
1815 const_iterator end1 = x.end(); | |
1816 const_iterator i1 = x.begin(); | |
1817 const_iterator i2 = y.begin(); | |
1818 if(tree_type::constant_time_size){ | |
1819 while (i1 != end1 && *i1 == *i2) { | |
1820 ++i1; | |
1821 ++i2; | |
1822 } | |
1823 return i1 == end1; | |
1824 } | |
1825 else{ | |
1826 const_iterator end2 = y.end(); | |
1827 while (i1 != end1 && i2 != end2 && *i1 == *i2) { | |
1828 ++i1; | |
1829 ++i2; | |
1830 } | |
1831 return i1 == end1 && i2 == end2; | |
1832 } | |
1833 } | |
1834 | |
1835 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
1836 template<class T, class ...Options> | |
1837 #else | |
1838 template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType> | |
1839 #endif | |
1840 inline bool operator!= | |
1841 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
1842 (const bstree_impl<T, Options...> &x, const bstree_impl<T, Options...> &y) | |
1843 #else | |
1844 ( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &x | |
1845 , const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &y) | |
1846 #endif | |
1847 { return !(x == y); } | |
1848 | |
1849 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
1850 template<class T, class ...Options> | |
1851 #else | |
1852 template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType> | |
1853 #endif | |
1854 inline bool operator> | |
1855 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
1856 (const bstree_impl<T, Options...> &x, const bstree_impl<T, Options...> &y) | |
1857 #else | |
1858 ( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &x | |
1859 , const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &y) | |
1860 #endif | |
1861 { return y < x; } | |
1862 | |
1863 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
1864 template<class T, class ...Options> | |
1865 #else | |
1866 template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType> | |
1867 #endif | |
1868 inline bool operator<= | |
1869 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
1870 (const bstree_impl<T, Options...> &x, const bstree_impl<T, Options...> &y) | |
1871 #else | |
1872 ( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &x | |
1873 , const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &y) | |
1874 #endif | |
1875 { return !(y < x); } | |
1876 | |
1877 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
1878 template<class T, class ...Options> | |
1879 #else | |
1880 template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType> | |
1881 #endif | |
1882 inline bool operator>= | |
1883 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
1884 (const bstree_impl<T, Options...> &x, const bstree_impl<T, Options...> &y) | |
1885 #else | |
1886 ( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &x | |
1887 , const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &y) | |
1888 #endif | |
1889 { return !(x < y); } | |
1890 | |
1891 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
1892 template<class T, class ...Options> | |
1893 #else | |
1894 template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType> | |
1895 #endif | |
1896 inline void swap | |
1897 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | |
1898 (bstree_impl<T, Options...> &x, bstree_impl<T, Options...> &y) | |
1899 #else | |
1900 ( bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &x | |
1901 , bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &y) | |
1902 #endif | |
1903 { x.swap(y); } | |
1904 | |
1905 //! Helper metafunction to define a \c bstree that yields to the same type when the | |
1906 //! same options (either explicitly or implicitly) are used. | |
1907 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | |
1908 template<class T, class ...Options> | |
1909 #else | |
1910 template<class T, class O1 = void, class O2 = void | |
1911 , class O3 = void, class O4 = void> | |
1912 #endif | |
1913 struct make_bstree | |
1914 { | |
1915 /// @cond | |
1916 typedef typename pack_options | |
1917 < bstree_defaults, | |
1918 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | |
1919 O1, O2, O3, O4 | |
1920 #else | |
1921 Options... | |
1922 #endif | |
1923 >::type packed_options; | |
1924 | |
1925 typedef typename detail::get_value_traits | |
1926 <T, typename packed_options::proto_value_traits>::type value_traits; | |
1927 | |
1928 typedef bstree_impl | |
1929 < value_traits | |
1930 , typename packed_options::compare | |
1931 , typename packed_options::size_type | |
1932 , packed_options::constant_time_size | |
1933 , BsTreeAlgorithms | |
1934 > implementation_defined; | |
1935 /// @endcond | |
1936 typedef implementation_defined type; | |
1937 }; | |
1938 | |
1939 | |
1940 #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED | |
1941 | |
1942 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | |
1943 template<class T, class O1, class O2, class O3, class O4> | |
1944 #else | |
1945 template<class T, class ...Options> | |
1946 #endif | |
1947 class bstree | |
1948 : public make_bstree<T, | |
1949 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | |
1950 O1, O2, O3, O4 | |
1951 #else | |
1952 Options... | |
1953 #endif | |
1954 >::type | |
1955 { | |
1956 typedef typename make_bstree | |
1957 <T, | |
1958 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | |
1959 O1, O2, O3, O4 | |
1960 #else | |
1961 Options... | |
1962 #endif | |
1963 >::type Base; | |
1964 BOOST_MOVABLE_BUT_NOT_COPYABLE(bstree) | |
1965 | |
1966 public: | |
1967 typedef typename Base::value_compare value_compare; | |
1968 typedef typename Base::value_traits value_traits; | |
1969 typedef typename Base::real_value_traits real_value_traits; | |
1970 typedef typename Base::iterator iterator; | |
1971 typedef typename Base::const_iterator const_iterator; | |
1972 | |
1973 //Assert if passed value traits are compatible with the type | |
1974 BOOST_STATIC_ASSERT((detail::is_same<typename real_value_traits::value_type, T>::value)); | |
1975 | |
1976 bstree( const value_compare &cmp = value_compare() | |
1977 , const value_traits &v_traits = value_traits()) | |
1978 : Base(cmp, v_traits) | |
1979 {} | |
1980 | |
1981 template<class Iterator> | |
1982 bstree( bool unique, Iterator b, Iterator e | |
1983 , const value_compare &cmp = value_compare() | |
1984 , const value_traits &v_traits = value_traits()) | |
1985 : Base(unique, b, e, cmp, v_traits) | |
1986 {} | |
1987 | |
1988 bstree(BOOST_RV_REF(bstree) x) | |
1989 : Base(::boost::move(static_cast<Base&>(x))) | |
1990 {} | |
1991 | |
1992 bstree& operator=(BOOST_RV_REF(bstree) x) | |
1993 { return static_cast<bstree &>(this->Base::operator=(::boost::move(static_cast<Base&>(x)))); } | |
1994 | |
1995 static bstree &container_from_end_iterator(iterator end_iterator) | |
1996 { return static_cast<bstree &>(Base::container_from_end_iterator(end_iterator)); } | |
1997 | |
1998 static const bstree &container_from_end_iterator(const_iterator end_iterator) | |
1999 { return static_cast<const bstree &>(Base::container_from_end_iterator(end_iterator)); } | |
2000 | |
2001 static bstree &container_from_iterator(iterator it) | |
2002 { return static_cast<bstree &>(Base::container_from_iterator(it)); } | |
2003 | |
2004 static const bstree &container_from_iterator(const_iterator it) | |
2005 { return static_cast<const bstree &>(Base::container_from_iterator(it)); } | |
2006 }; | |
2007 | |
2008 #endif | |
2009 } //namespace intrusive | |
2010 } //namespace boost | |
2011 | |
2012 #include <boost/intrusive/detail/config_end.hpp> | |
2013 | |
2014 #endif //BOOST_INTRUSIVE_BSTREE_HPP |