Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/intrusive/treap.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
comparison
equal
deleted
inserted
replaced
100:793467b5e61c | 101:c530137014c0 |
---|---|
11 ///////////////////////////////////////////////////////////////////////////// | 11 ///////////////////////////////////////////////////////////////////////////// |
12 #ifndef BOOST_INTRUSIVE_TREAP_HPP | 12 #ifndef BOOST_INTRUSIVE_TREAP_HPP |
13 #define BOOST_INTRUSIVE_TREAP_HPP | 13 #define BOOST_INTRUSIVE_TREAP_HPP |
14 | 14 |
15 #include <boost/intrusive/detail/config_begin.hpp> | 15 #include <boost/intrusive/detail/config_begin.hpp> |
16 #include <algorithm> | 16 #include <boost/intrusive/intrusive_fwd.hpp> |
17 #include <cstddef> | |
18 #include <functional> | |
19 #include <iterator> | |
20 #include <utility> | |
21 | 17 |
22 #include <boost/intrusive/detail/assert.hpp> | 18 #include <boost/intrusive/detail/assert.hpp> |
23 #include <boost/static_assert.hpp> | |
24 #include <boost/intrusive/intrusive_fwd.hpp> | |
25 #include <boost/intrusive/bs_set_hook.hpp> | 19 #include <boost/intrusive/bs_set_hook.hpp> |
26 #include <boost/intrusive/bstree.hpp> | 20 #include <boost/intrusive/bstree.hpp> |
27 #include <boost/intrusive/detail/tree_node.hpp> | 21 #include <boost/intrusive/detail/tree_node.hpp> |
28 #include <boost/intrusive/detail/ebo_functor_holder.hpp> | 22 #include <boost/intrusive/detail/ebo_functor_holder.hpp> |
29 #include <boost/intrusive/pointer_traits.hpp> | 23 #include <boost/intrusive/pointer_traits.hpp> |
30 #include <boost/intrusive/detail/utilities.hpp> | 24 #include <boost/intrusive/detail/get_value_traits.hpp> |
31 #include <boost/intrusive/pointer_traits.hpp> | |
32 #include <boost/intrusive/options.hpp> | |
33 #include <boost/intrusive/detail/mpl.hpp> | 25 #include <boost/intrusive/detail/mpl.hpp> |
34 #include <boost/intrusive/treap_algorithms.hpp> | 26 #include <boost/intrusive/treap_algorithms.hpp> |
35 #include <boost/intrusive/link_mode.hpp> | 27 #include <boost/intrusive/link_mode.hpp> |
36 #include <boost/move/move.hpp> | |
37 #include <boost/intrusive/priority_compare.hpp> | 28 #include <boost/intrusive/priority_compare.hpp> |
29 #include <boost/intrusive/detail/node_cloner_disposer.hpp> | |
30 #include <boost/intrusive/detail/key_nodeptr_comp.hpp> | |
31 | |
32 #include <boost/static_assert.hpp> | |
33 #include <boost/move/utility_core.hpp> | |
34 #include <boost/move/adl_move_swap.hpp> | |
35 | |
36 #include <cstddef> | |
37 #include <boost/intrusive/detail/minimal_less_equal_header.hpp> | |
38 #include <boost/intrusive/detail/minimal_pair_header.hpp> //std::pair | |
39 | |
40 #if defined(BOOST_HAS_PRAGMA_ONCE) | |
41 # pragma once | |
42 #endif | |
38 | 43 |
39 namespace boost { | 44 namespace boost { |
40 namespace intrusive { | 45 namespace intrusive { |
41 | 46 |
42 /// @cond | 47 /// @cond |
43 | 48 |
44 struct treap_defaults | 49 struct treap_defaults |
45 { | 50 { |
46 typedef detail::default_bstree_hook proto_value_traits; | 51 typedef default_bstree_hook_applier proto_value_traits; |
47 static const bool constant_time_size = true; | 52 static const bool constant_time_size = true; |
48 typedef std::size_t size_type; | 53 typedef std::size_t size_type; |
49 typedef void compare; | 54 typedef void compare; |
50 typedef void priority; | 55 typedef void priority; |
56 typedef void header_holder_type; | |
51 }; | 57 }; |
52 | 58 |
53 /// @endcond | 59 /// @endcond |
54 | 60 |
55 //! The class template treap is an intrusive treap container that | 61 //! The class template treap is an intrusive treap container that |
66 //! \c constant_time_size<>, \c size_type<>, | 72 //! \c constant_time_size<>, \c size_type<>, |
67 //! \c compare<> and \c priority_compare<> | 73 //! \c compare<> and \c priority_compare<> |
68 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | 74 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) |
69 template<class T, class ...Options> | 75 template<class T, class ...Options> |
70 #else | 76 #else |
71 template<class ValueTraits, class VoidOrKeyComp, class VoidOrPrioComp, class SizeType, bool ConstantTimeSize> | 77 template<class ValueTraits, class VoidOrKeyComp, class VoidOrPrioComp, class SizeType, bool ConstantTimeSize, typename HeaderHolder> |
72 #endif | 78 #endif |
73 class treap_impl | 79 class treap_impl |
74 /// @cond | 80 /// @cond |
75 : public bstree_impl<ValueTraits, VoidOrKeyComp, SizeType, ConstantTimeSize, BsTreeAlgorithms> | 81 : public bstree_impl<ValueTraits, VoidOrKeyComp, SizeType, ConstantTimeSize, BsTreeAlgorithms, HeaderHolder> |
76 , public detail::ebo_functor_holder | 82 //Use public inheritance to avoid MSVC bugs with closures |
83 , public detail::ebo_functor_holder | |
77 < typename get_prio | 84 < typename get_prio |
78 < VoidOrPrioComp | 85 < VoidOrPrioComp |
79 , typename bstree_impl | 86 , typename bstree_impl |
80 <ValueTraits, VoidOrKeyComp, SizeType, ConstantTimeSize, BsTreeAlgorithms>::value_type>::type | 87 <ValueTraits, VoidOrKeyComp, SizeType, ConstantTimeSize, BsTreeAlgorithms, HeaderHolder>::value_type>::type |
81 > | 88 > |
82 /// @endcond | 89 /// @endcond |
83 { | 90 { |
84 public: | 91 public: |
85 typedef ValueTraits value_traits; | 92 typedef ValueTraits value_traits; |
86 /// @cond | 93 /// @cond |
87 typedef bstree_impl< ValueTraits, VoidOrKeyComp, SizeType | 94 typedef bstree_impl< ValueTraits, VoidOrKeyComp, SizeType |
88 , ConstantTimeSize, BsTreeAlgorithms> tree_type; | 95 , ConstantTimeSize, BsTreeAlgorithms |
96 , HeaderHolder> tree_type; | |
89 typedef tree_type implementation_defined; | 97 typedef tree_type implementation_defined; |
90 typedef typename tree_type::real_value_traits real_value_traits; | |
91 typedef get_prio | 98 typedef get_prio |
92 < VoidOrPrioComp | 99 < VoidOrPrioComp |
93 , typename tree_type::value_type> get_prio_type; | 100 , typename tree_type::value_type> get_prio_type; |
94 | 101 |
95 typedef detail::ebo_functor_holder | 102 typedef detail::ebo_functor_holder |
118 typedef BOOST_INTRUSIVE_IMPDEF(treap_algorithms<node_traits>) node_algorithms; | 125 typedef BOOST_INTRUSIVE_IMPDEF(treap_algorithms<node_traits>) node_algorithms; |
119 typedef BOOST_INTRUSIVE_IMPDEF(typename get_prio_type::type) priority_compare; | 126 typedef BOOST_INTRUSIVE_IMPDEF(typename get_prio_type::type) priority_compare; |
120 | 127 |
121 static const bool constant_time_size = implementation_defined::constant_time_size; | 128 static const bool constant_time_size = implementation_defined::constant_time_size; |
122 static const bool stateful_value_traits = implementation_defined::stateful_value_traits; | 129 static const bool stateful_value_traits = implementation_defined::stateful_value_traits; |
123 static const bool safemode_or_autounlink = is_safe_autounlink<real_value_traits::link_mode>::value; | 130 static const bool safemode_or_autounlink = is_safe_autounlink<value_traits::link_mode>::value; |
124 | 131 |
125 /// @cond | 132 /// @cond |
126 private: | 133 private: |
127 | 134 |
128 //noncopyable | 135 //noncopyable |
178 this->insert_equal(b, e); | 185 this->insert_equal(b, e); |
179 } | 186 } |
180 | 187 |
181 //! @copydoc ::boost::intrusive::bstree::bstree(bstree &&) | 188 //! @copydoc ::boost::intrusive::bstree::bstree(bstree &&) |
182 treap_impl(BOOST_RV_REF(treap_impl) x) | 189 treap_impl(BOOST_RV_REF(treap_impl) x) |
183 : tree_type(::boost::move(static_cast<tree_type&>(x))) | 190 : tree_type(BOOST_MOVE_BASE(tree_type, x)) |
184 , prio_base(::boost::move(x.priv_pcomp())) | 191 , prio_base(::boost::move(x.priv_pcomp())) |
185 {} | 192 {} |
186 | 193 |
187 //! @copydoc ::boost::intrusive::bstree::operator=(bstree &&) | 194 //! @copydoc ::boost::intrusive::bstree::operator=(bstree &&) |
188 treap_impl& operator=(BOOST_RV_REF(treap_impl) x) | 195 treap_impl& operator=(BOOST_RV_REF(treap_impl) x) |
215 //! | 222 //! |
216 //! <b>Complexity</b>: Constant. | 223 //! <b>Complexity</b>: Constant. |
217 //! | 224 //! |
218 //! <b>Throws</b>: Nothing. | 225 //! <b>Throws</b>: Nothing. |
219 iterator top() | 226 iterator top() |
220 { return this->empty() ? this->end() : iterator(node_traits::get_parent(this->tree_type::header_ptr()), this); } | 227 { return this->tree_type::root(); } |
221 | 228 |
222 //! <b>Effects</b>: Returns a const_iterator pointing to the highest priority object of the treap.. | 229 //! <b>Effects</b>: Returns a const_iterator pointing to the highest priority object of the treap.. |
223 //! | 230 //! |
224 //! <b>Complexity</b>: Constant. | 231 //! <b>Complexity</b>: Constant. |
225 //! | 232 //! |
231 //! | 238 //! |
232 //! <b>Complexity</b>: Constant. | 239 //! <b>Complexity</b>: Constant. |
233 //! | 240 //! |
234 //! <b>Throws</b>: Nothing. | 241 //! <b>Throws</b>: Nothing. |
235 const_iterator ctop() const | 242 const_iterator ctop() const |
236 { return this->empty() ? this->cend() : const_iterator(node_traits::get_parent(this->tree_type::header_ptr()), this); } | 243 { return this->tree_type::root(); } |
237 | 244 |
238 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED | 245 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED |
239 //! @copydoc ::boost::intrusive::bstree::rbegin() | 246 //! @copydoc ::boost::intrusive::bstree::rbegin() |
240 reverse_iterator rbegin(); | 247 reverse_iterator rbegin(); |
241 | 248 |
323 //! <b>Throws</b>: If the comparison functor's swap call throws. | 330 //! <b>Throws</b>: If the comparison functor's swap call throws. |
324 void swap(treap_impl& other) | 331 void swap(treap_impl& other) |
325 { | 332 { |
326 tree_type::swap(other); | 333 tree_type::swap(other); |
327 //This can throw | 334 //This can throw |
328 using std::swap; | 335 ::boost::adl_move_swap(this->priv_pcomp(), other.priv_pcomp()); |
329 swap(this->priv_pcomp(), other.priv_pcomp()); | |
330 } | 336 } |
331 | 337 |
332 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. | 338 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. |
333 //! Cloner should yield to nodes equivalent to the original nodes. | 339 //! Cloner should yield to nodes equivalent to the original nodes. |
334 //! | 340 //! |
361 //! | 367 //! |
362 //! <b>Note</b>: Does not affect the validity of iterators and references. | 368 //! <b>Note</b>: Does not affect the validity of iterators and references. |
363 //! No copy-constructors are called. | 369 //! No copy-constructors are called. |
364 iterator insert_equal(reference value) | 370 iterator insert_equal(reference value) |
365 { | 371 { |
366 detail::key_nodeptr_comp<value_compare, real_value_traits> | 372 detail::key_nodeptr_comp<value_compare, value_traits> |
367 key_node_comp(this->value_comp(), &this->get_real_value_traits()); | 373 key_node_comp(this->value_comp(), &this->get_value_traits()); |
368 detail::key_nodeptr_comp<priority_compare, real_value_traits> | 374 detail::key_nodeptr_comp<priority_compare, value_traits> |
369 key_node_pcomp(this->priv_pcomp(), &this->get_real_value_traits()); | 375 key_node_pcomp(this->priv_pcomp(), &this->get_value_traits()); |
370 node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value)); | 376 node_ptr to_insert(this->get_value_traits().to_node_ptr(value)); |
371 if(safemode_or_autounlink) | 377 if(safemode_or_autounlink) |
372 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); | 378 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); |
373 iterator ret(node_algorithms::insert_equal_upper_bound | 379 iterator ret(node_algorithms::insert_equal_upper_bound |
374 (this->tree_type::header_ptr(), to_insert, key_node_comp, key_node_pcomp), this->real_value_traits_ptr()); | 380 (this->tree_type::header_ptr(), to_insert, key_node_comp, key_node_pcomp), this->priv_value_traits_ptr()); |
375 this->tree_type::sz_traits().increment(); | 381 this->tree_type::sz_traits().increment(); |
376 return ret; | 382 return ret; |
377 } | 383 } |
378 | 384 |
379 //! <b>Requires</b>: value must be an lvalue, and "hint" must be | 385 //! <b>Requires</b>: value must be an lvalue, and "hint" must be |
390 //! | 396 //! |
391 //! <b>Note</b>: Does not affect the validity of iterators and references. | 397 //! <b>Note</b>: Does not affect the validity of iterators and references. |
392 //! No copy-constructors are called. | 398 //! No copy-constructors are called. |
393 iterator insert_equal(const_iterator hint, reference value) | 399 iterator insert_equal(const_iterator hint, reference value) |
394 { | 400 { |
395 detail::key_nodeptr_comp<value_compare, real_value_traits> | 401 detail::key_nodeptr_comp<value_compare, value_traits> |
396 key_node_comp(this->value_comp(), &this->get_real_value_traits()); | 402 key_node_comp(this->value_comp(), &this->get_value_traits()); |
397 detail::key_nodeptr_comp<priority_compare, real_value_traits> | 403 detail::key_nodeptr_comp<priority_compare, value_traits> |
398 key_node_pcomp(this->priv_pcomp(), &this->get_real_value_traits()); | 404 key_node_pcomp(this->priv_pcomp(), &this->get_value_traits()); |
399 node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value)); | 405 node_ptr to_insert(this->get_value_traits().to_node_ptr(value)); |
400 if(safemode_or_autounlink) | 406 if(safemode_or_autounlink) |
401 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); | 407 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); |
402 iterator ret (node_algorithms::insert_equal | 408 iterator ret (node_algorithms::insert_equal |
403 (this->tree_type::header_ptr(), hint.pointed_node(), to_insert, key_node_comp, key_node_pcomp), this->real_value_traits_ptr()); | 409 (this->tree_type::header_ptr(), hint.pointed_node(), to_insert, key_node_comp, key_node_pcomp), this->priv_value_traits_ptr()); |
404 this->tree_type::sz_traits().increment(); | 410 this->tree_type::sz_traits().increment(); |
405 return ret; | 411 return ret; |
406 } | 412 } |
407 | 413 |
408 //! <b>Requires</b>: Dereferencing iterator must yield an lvalue | 414 //! <b>Requires</b>: Dereferencing iterator must yield an lvalue |
538 template<class KeyType, class KeyValueCompare, class KeyValuePrioCompare> | 544 template<class KeyType, class KeyValueCompare, class KeyValuePrioCompare> |
539 std::pair<iterator, bool> insert_unique_check | 545 std::pair<iterator, bool> insert_unique_check |
540 ( const KeyType &key, KeyValueCompare key_value_comp | 546 ( const KeyType &key, KeyValueCompare key_value_comp |
541 , KeyValuePrioCompare key_value_pcomp, insert_commit_data &commit_data) | 547 , KeyValuePrioCompare key_value_pcomp, insert_commit_data &commit_data) |
542 { | 548 { |
543 detail::key_nodeptr_comp<KeyValueCompare, real_value_traits> | 549 detail::key_nodeptr_comp<KeyValueCompare, value_traits> |
544 ocomp(key_value_comp, &this->get_real_value_traits()); | 550 ocomp(key_value_comp, &this->get_value_traits()); |
545 detail::key_nodeptr_comp<KeyValuePrioCompare, real_value_traits> | 551 detail::key_nodeptr_comp<KeyValuePrioCompare, value_traits> |
546 pcomp(key_value_pcomp, &this->get_real_value_traits()); | 552 pcomp(key_value_pcomp, &this->get_value_traits()); |
547 std::pair<node_ptr, bool> ret = | 553 std::pair<node_ptr, bool> ret = |
548 (node_algorithms::insert_unique_check | 554 (node_algorithms::insert_unique_check |
549 (this->tree_type::header_ptr(), key, ocomp, pcomp, commit_data)); | 555 (this->tree_type::header_ptr(), key, ocomp, pcomp, commit_data)); |
550 return std::pair<iterator, bool>(iterator(ret.first, this->real_value_traits_ptr()), ret.second); | 556 return std::pair<iterator, bool>(iterator(ret.first, this->priv_value_traits_ptr()), ret.second); |
551 } | 557 } |
552 | 558 |
553 //! <b>Requires</b>: key_value_comp must be a comparison function that induces | 559 //! <b>Requires</b>: key_value_comp must be a comparison function that induces |
554 //! the same strict weak ordering as value_compare. | 560 //! the same strict weak ordering as value_compare. |
555 //! key_value_pcomp must be a comparison function that induces | 561 //! key_value_pcomp must be a comparison function that induces |
590 ( const_iterator hint, const KeyType &key | 596 ( const_iterator hint, const KeyType &key |
591 , KeyValueCompare key_value_comp | 597 , KeyValueCompare key_value_comp |
592 , KeyValuePrioCompare key_value_pcomp | 598 , KeyValuePrioCompare key_value_pcomp |
593 , insert_commit_data &commit_data) | 599 , insert_commit_data &commit_data) |
594 { | 600 { |
595 detail::key_nodeptr_comp<KeyValueCompare, real_value_traits> | 601 detail::key_nodeptr_comp<KeyValueCompare, value_traits> |
596 ocomp(key_value_comp, &this->get_real_value_traits()); | 602 ocomp(key_value_comp, &this->get_value_traits()); |
597 detail::key_nodeptr_comp<KeyValuePrioCompare, real_value_traits> | 603 detail::key_nodeptr_comp<KeyValuePrioCompare, value_traits> |
598 pcomp(key_value_pcomp, &this->get_real_value_traits()); | 604 pcomp(key_value_pcomp, &this->get_value_traits()); |
599 std::pair<node_ptr, bool> ret = | 605 std::pair<node_ptr, bool> ret = |
600 (node_algorithms::insert_unique_check | 606 (node_algorithms::insert_unique_check |
601 (this->tree_type::header_ptr(), hint.pointed_node(), key, ocomp, pcomp, commit_data)); | 607 (this->tree_type::header_ptr(), hint.pointed_node(), key, ocomp, pcomp, commit_data)); |
602 return std::pair<iterator, bool>(iterator(ret.first, this->real_value_traits_ptr()), ret.second); | 608 return std::pair<iterator, bool>(iterator(ret.first, this->priv_value_traits_ptr()), ret.second); |
603 } | 609 } |
604 | 610 |
605 //! <b>Requires</b>: value must be an lvalue of type value_type. commit_data | 611 //! <b>Requires</b>: value must be an lvalue of type value_type. commit_data |
606 //! must have been obtained from a previous call to "insert_check". | 612 //! must have been obtained from a previous call to "insert_check". |
607 //! No objects should have been inserted or erased from the container between | 613 //! No objects should have been inserted or erased from the container between |
619 //! <b>Notes</b>: This function has only sense if a "insert_check" has been | 625 //! <b>Notes</b>: This function has only sense if a "insert_check" has been |
620 //! previously executed to fill "commit_data". No value should be inserted or | 626 //! previously executed to fill "commit_data". No value should be inserted or |
621 //! erased between the "insert_check" and "insert_commit" calls. | 627 //! erased between the "insert_check" and "insert_commit" calls. |
622 iterator insert_unique_commit(reference value, const insert_commit_data &commit_data) | 628 iterator insert_unique_commit(reference value, const insert_commit_data &commit_data) |
623 { | 629 { |
624 node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value)); | 630 node_ptr to_insert(this->get_value_traits().to_node_ptr(value)); |
625 if(safemode_or_autounlink) | 631 if(safemode_or_autounlink) |
626 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); | 632 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); |
627 node_algorithms::insert_unique_commit(this->tree_type::header_ptr(), to_insert, commit_data); | 633 node_algorithms::insert_unique_commit(this->tree_type::header_ptr(), to_insert, commit_data); |
628 this->tree_type::sz_traits().increment(); | 634 this->tree_type::sz_traits().increment(); |
629 return iterator(to_insert, this->real_value_traits_ptr()); | 635 return iterator(to_insert, this->priv_value_traits_ptr()); |
630 } | 636 } |
631 | 637 |
632 //! <b>Requires</b>: value must be an lvalue, "pos" must be | 638 //! <b>Requires</b>: value must be an lvalue, "pos" must be |
633 //! a valid iterator (or end) and must be the succesor of value | 639 //! a valid iterator (or end) and must be the succesor of value |
634 //! once inserted according to the predicate | 640 //! once inserted according to the predicate |
643 //! the successor of "value" container ordering invariant will be broken. | 649 //! the successor of "value" container ordering invariant will be broken. |
644 //! This is a low-level function to be used only for performance reasons | 650 //! This is a low-level function to be used only for performance reasons |
645 //! by advanced users. | 651 //! by advanced users. |
646 iterator insert_before(const_iterator pos, reference value) | 652 iterator insert_before(const_iterator pos, reference value) |
647 { | 653 { |
648 node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value)); | 654 node_ptr to_insert(this->get_value_traits().to_node_ptr(value)); |
649 if(safemode_or_autounlink) | 655 if(safemode_or_autounlink) |
650 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); | 656 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); |
651 detail::key_nodeptr_comp<priority_compare, real_value_traits> | 657 detail::key_nodeptr_comp<priority_compare, value_traits> |
652 pcomp(this->priv_pcomp(), &this->get_real_value_traits()); | 658 pcomp(this->priv_pcomp(), &this->get_value_traits()); |
653 iterator ret (node_algorithms::insert_before | 659 iterator ret (node_algorithms::insert_before |
654 (this->tree_type::header_ptr(), pos.pointed_node(), to_insert, pcomp), this->real_value_traits_ptr()); | 660 (this->tree_type::header_ptr(), pos.pointed_node(), to_insert, pcomp), this->priv_value_traits_ptr()); |
655 this->tree_type::sz_traits().increment(); | 661 this->tree_type::sz_traits().increment(); |
656 return ret; | 662 return ret; |
657 } | 663 } |
658 | 664 |
659 //! <b>Requires</b>: value must be an lvalue, and it must be no less | 665 //! <b>Requires</b>: value must be an lvalue, and it must be no less |
670 //! This function is slightly more efficient than using "insert_before". | 676 //! This function is slightly more efficient than using "insert_before". |
671 //! This is a low-level function to be used only for performance reasons | 677 //! This is a low-level function to be used only for performance reasons |
672 //! by advanced users. | 678 //! by advanced users. |
673 void push_back(reference value) | 679 void push_back(reference value) |
674 { | 680 { |
675 node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value)); | 681 node_ptr to_insert(this->get_value_traits().to_node_ptr(value)); |
676 if(safemode_or_autounlink) | 682 if(safemode_or_autounlink) |
677 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); | 683 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); |
678 detail::key_nodeptr_comp<priority_compare, real_value_traits> | 684 detail::key_nodeptr_comp<priority_compare, value_traits> |
679 pcomp(this->priv_pcomp(), &this->get_real_value_traits()); | 685 pcomp(this->priv_pcomp(), &this->get_value_traits()); |
680 node_algorithms::push_back(this->tree_type::header_ptr(), to_insert, pcomp); | 686 node_algorithms::push_back(this->tree_type::header_ptr(), to_insert, pcomp); |
681 this->tree_type::sz_traits().increment(); | 687 this->tree_type::sz_traits().increment(); |
682 } | 688 } |
683 | 689 |
684 //! <b>Requires</b>: value must be an lvalue, and it must be no greater | 690 //! <b>Requires</b>: value must be an lvalue, and it must be no greater |
695 //! This function is slightly more efficient than using "insert_before". | 701 //! This function is slightly more efficient than using "insert_before". |
696 //! This is a low-level function to be used only for performance reasons | 702 //! This is a low-level function to be used only for performance reasons |
697 //! by advanced users. | 703 //! by advanced users. |
698 void push_front(reference value) | 704 void push_front(reference value) |
699 { | 705 { |
700 node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value)); | 706 node_ptr to_insert(this->get_value_traits().to_node_ptr(value)); |
701 if(safemode_or_autounlink) | 707 if(safemode_or_autounlink) |
702 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); | 708 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); |
703 detail::key_nodeptr_comp<priority_compare, real_value_traits> | 709 detail::key_nodeptr_comp<priority_compare, value_traits> |
704 pcomp(this->priv_pcomp(), &this->get_real_value_traits()); | 710 pcomp(this->priv_pcomp(), &this->get_value_traits()); |
705 node_algorithms::push_front(this->tree_type::header_ptr(), to_insert, pcomp); | 711 node_algorithms::push_front(this->tree_type::header_ptr(), to_insert, pcomp); |
706 this->tree_type::sz_traits().increment(); | 712 this->tree_type::sz_traits().increment(); |
707 } | 713 } |
708 | 714 |
709 //! <b>Effects</b>: Erases the element pointed to by pos. | 715 //! <b>Effects</b>: Erases the element pointed to by i. |
710 //! | 716 //! |
711 //! <b>Complexity</b>: Average complexity for erase element is constant time. | 717 //! <b>Complexity</b>: Average complexity for erase element is constant time. |
712 //! | 718 //! |
713 //! <b>Throws</b>: if the internal priority_compare function throws. Strong guarantee. | 719 //! <b>Throws</b>: if the internal priority_compare function throws. Strong guarantee. |
714 //! | 720 //! |
719 const_iterator ret(i); | 725 const_iterator ret(i); |
720 ++ret; | 726 ++ret; |
721 node_ptr to_erase(i.pointed_node()); | 727 node_ptr to_erase(i.pointed_node()); |
722 if(safemode_or_autounlink) | 728 if(safemode_or_autounlink) |
723 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!node_algorithms::unique(to_erase)); | 729 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!node_algorithms::unique(to_erase)); |
724 detail::key_nodeptr_comp<priority_compare, real_value_traits> | 730 detail::key_nodeptr_comp<priority_compare, value_traits> |
725 key_node_pcomp(this->priv_pcomp(), &this->get_real_value_traits()); | 731 key_node_pcomp(this->priv_pcomp(), &this->get_value_traits()); |
726 node_algorithms::erase(this->tree_type::header_ptr(), to_erase, key_node_pcomp); | 732 node_algorithms::erase(this->tree_type::header_ptr(), to_erase, key_node_pcomp); |
727 this->tree_type::sz_traits().decrement(); | 733 this->tree_type::sz_traits().decrement(); |
728 if(safemode_or_autounlink) | 734 if(safemode_or_autounlink) |
729 node_algorithms::init(to_erase); | 735 node_algorithms::init(to_erase); |
730 return ret.unconst(); | 736 return ret.unconst(); |
780 return n; | 786 return n; |
781 } | 787 } |
782 | 788 |
783 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. | 789 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. |
784 //! | 790 //! |
785 //! <b>Effects</b>: Erases the element pointed to by pos. | 791 //! <b>Effects</b>: Erases the element pointed to by i. |
786 //! Disposer::operator()(pointer) is called for the removed element. | 792 //! Disposer::operator()(pointer) is called for the removed element. |
787 //! | 793 //! |
788 //! <b>Complexity</b>: Average complexity for erase element is constant time. | 794 //! <b>Complexity</b>: Average complexity for erase element is constant time. |
789 //! | 795 //! |
790 //! <b>Throws</b>: if the internal priority_compare function throws. Strong guarantee. | 796 //! <b>Throws</b>: if the internal priority_compare function throws. Strong guarantee. |
794 template<class Disposer> | 800 template<class Disposer> |
795 iterator erase_and_dispose(const_iterator i, Disposer disposer) | 801 iterator erase_and_dispose(const_iterator i, Disposer disposer) |
796 { | 802 { |
797 node_ptr to_erase(i.pointed_node()); | 803 node_ptr to_erase(i.pointed_node()); |
798 iterator ret(this->erase(i)); | 804 iterator ret(this->erase(i)); |
799 disposer(this->get_real_value_traits().to_value_ptr(to_erase)); | 805 disposer(this->get_value_traits().to_value_ptr(to_erase)); |
800 return ret; | 806 return ret; |
801 } | 807 } |
802 | 808 |
803 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | 809 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) |
804 template<class Disposer> | 810 template<class Disposer> |
896 //! to the erased elements. Calls N times to disposer functor. | 902 //! to the erased elements. Calls N times to disposer functor. |
897 template<class Disposer> | 903 template<class Disposer> |
898 void clear_and_dispose(Disposer disposer) | 904 void clear_and_dispose(Disposer disposer) |
899 { | 905 { |
900 node_algorithms::clear_and_dispose(this->tree_type::header_ptr() | 906 node_algorithms::clear_and_dispose(this->tree_type::header_ptr() |
901 , detail::node_disposer<Disposer, real_value_traits, TreapAlgorithms>(disposer, &this->get_real_value_traits())); | 907 , detail::node_disposer<Disposer, value_traits, TreapAlgorithms>(disposer, &this->get_value_traits())); |
902 node_algorithms::init_header(this->tree_type::header_ptr()); | 908 node_algorithms::init_header(this->tree_type::header_ptr()); |
903 this->tree_type::sz_traits().set_size(0); | 909 this->tree_type::sz_traits().set_size(0); |
904 } | 910 } |
911 | |
912 //! @copydoc ::boost::intrusive::bstree::check(ExtraChecker)const | |
913 template <class ExtraChecker> | |
914 void check(ExtraChecker extra_checker) const | |
915 { | |
916 typedef detail::key_nodeptr_comp<priority_compare, value_traits> nodeptr_prio_comp_t; | |
917 nodeptr_prio_comp_t nodeptr_prio_comp(priv_pcomp(), &this->get_value_traits()); | |
918 tree_type::check(detail::treap_node_extra_checker<ValueTraits, nodeptr_prio_comp_t, ExtraChecker>(nodeptr_prio_comp, extra_checker)); | |
919 } | |
920 | |
921 //! @copydoc ::boost::intrusive::bstree::check()const | |
922 void check() const | |
923 { check(detail::empty_node_checker<ValueTraits>()); } | |
905 | 924 |
906 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED | 925 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED |
907 //! @copydoc ::boost::intrusive::bstree::count(const_reference)const | 926 //! @copydoc ::boost::intrusive::bstree::count(const_reference)const |
908 size_type count(const_reference value) const; | 927 size_type count(const_reference value) const; |
909 | 928 |
910 //! @copydoc ::boost::intrusive::bstree::count(const KeyType&,KeyValueCompare)const | 929 //! @copydoc ::boost::intrusive::bstree::count(const KeyType&,KeyValueCompare)const |
911 template<class KeyType, class KeyValueCompare> | 930 template<class KeyType, class KeyValueCompare> |
912 size_type count(const KeyType& key, KeyValueCompare comp) const; | 931 size_type count(const KeyType& key, KeyValueCompare comp) const; |
913 | 932 |
914 //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference) | 933 //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference) |
915 iterator lower_bound(const_reference value); | 934 iterator lower_bound(const_reference value); |
916 | 935 |
917 //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare) | 936 //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare) |
918 template<class KeyType, class KeyValueCompare> | 937 template<class KeyType, class KeyValueCompare> |
919 iterator lower_bound(const KeyType& key, KeyValueCompare comp); | 938 iterator lower_bound(const KeyType& key, KeyValueCompare comp); |
920 | 939 |
921 //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference)const | 940 //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference)const |
1061 //! same options (either explicitly or implicitly) are used. | 1080 //! same options (either explicitly or implicitly) are used. |
1062 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | 1081 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) |
1063 template<class T, class ...Options> | 1082 template<class T, class ...Options> |
1064 #else | 1083 #else |
1065 template<class T, class O1 = void, class O2 = void | 1084 template<class T, class O1 = void, class O2 = void |
1066 , class O3 = void, class O4 = void> | 1085 , class O3 = void, class O4 = void |
1086 , class O5 = void> | |
1067 #endif | 1087 #endif |
1068 struct make_treap | 1088 struct make_treap |
1069 { | 1089 { |
1070 typedef typename pack_options | 1090 typedef typename pack_options |
1071 < treap_defaults, | 1091 < treap_defaults, |
1072 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | 1092 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) |
1073 O1, O2, O3, O4 | 1093 O1, O2, O3, O4, O5 |
1074 #else | 1094 #else |
1075 Options... | 1095 Options... |
1076 #endif | 1096 #endif |
1077 >::type packed_options; | 1097 >::type packed_options; |
1078 | 1098 |
1083 < value_traits | 1103 < value_traits |
1084 , typename packed_options::compare | 1104 , typename packed_options::compare |
1085 , typename packed_options::priority | 1105 , typename packed_options::priority |
1086 , typename packed_options::size_type | 1106 , typename packed_options::size_type |
1087 , packed_options::constant_time_size | 1107 , packed_options::constant_time_size |
1108 , typename packed_options::header_holder_type | |
1088 > implementation_defined; | 1109 > implementation_defined; |
1089 /// @endcond | 1110 /// @endcond |
1090 typedef implementation_defined type; | 1111 typedef implementation_defined type; |
1091 }; | 1112 }; |
1092 | 1113 |
1093 #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED | 1114 #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED |
1094 | 1115 |
1095 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | 1116 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) |
1096 template<class T, class O1, class O2, class O3, class O4> | 1117 template<class T, class O1, class O2, class O3, class O4, class O5> |
1097 #else | 1118 #else |
1098 template<class T, class ...Options> | 1119 template<class T, class ...Options> |
1099 #endif | 1120 #endif |
1100 class treap | 1121 class treap |
1101 : public make_treap<T, | 1122 : public make_treap<T, |
1102 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | 1123 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) |
1103 O1, O2, O3, O4 | 1124 O1, O2, O3, O4, O5 |
1104 #else | 1125 #else |
1105 Options... | 1126 Options... |
1106 #endif | 1127 #endif |
1107 >::type | 1128 >::type |
1108 { | 1129 { |
1109 typedef typename make_treap | 1130 typedef typename make_treap |
1110 <T, | 1131 <T, |
1111 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | 1132 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) |
1112 O1, O2, O3, O4 | 1133 O1, O2, O3, O4, O5 |
1113 #else | 1134 #else |
1114 Options... | 1135 Options... |
1115 #endif | 1136 #endif |
1116 >::type Base; | 1137 >::type Base; |
1117 BOOST_MOVABLE_BUT_NOT_COPYABLE(treap) | 1138 BOOST_MOVABLE_BUT_NOT_COPYABLE(treap) |
1118 | 1139 |
1119 public: | 1140 public: |
1120 typedef typename Base::value_compare value_compare; | 1141 typedef typename Base::value_compare value_compare; |
1121 typedef typename Base::priority_compare priority_compare; | 1142 typedef typename Base::priority_compare priority_compare; |
1122 typedef typename Base::value_traits value_traits; | 1143 typedef typename Base::value_traits value_traits; |
1123 typedef typename Base::real_value_traits real_value_traits; | |
1124 typedef typename Base::iterator iterator; | 1144 typedef typename Base::iterator iterator; |
1125 typedef typename Base::const_iterator const_iterator; | 1145 typedef typename Base::const_iterator const_iterator; |
1126 typedef typename Base::reverse_iterator reverse_iterator; | 1146 typedef typename Base::reverse_iterator reverse_iterator; |
1127 typedef typename Base::const_reverse_iterator const_reverse_iterator; | 1147 typedef typename Base::const_reverse_iterator const_reverse_iterator; |
1128 | 1148 |
1129 //Assert if passed value traits are compatible with the type | 1149 //Assert if passed value traits are compatible with the type |
1130 BOOST_STATIC_ASSERT((detail::is_same<typename real_value_traits::value_type, T>::value)); | 1150 BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value)); |
1131 | 1151 |
1132 explicit treap( const value_compare &cmp = value_compare() | 1152 explicit treap( const value_compare &cmp = value_compare() |
1133 , const priority_compare &pcmp = priority_compare() | 1153 , const priority_compare &pcmp = priority_compare() |
1134 , const value_traits &v_traits = value_traits()) | 1154 , const value_traits &v_traits = value_traits()) |
1135 : Base(cmp, pcmp, v_traits) | 1155 : Base(cmp, pcmp, v_traits) |
1142 , const value_traits &v_traits = value_traits()) | 1162 , const value_traits &v_traits = value_traits()) |
1143 : Base(unique, b, e, cmp, pcmp, v_traits) | 1163 : Base(unique, b, e, cmp, pcmp, v_traits) |
1144 {} | 1164 {} |
1145 | 1165 |
1146 treap(BOOST_RV_REF(treap) x) | 1166 treap(BOOST_RV_REF(treap) x) |
1147 : Base(::boost::move(static_cast<Base&>(x))) | 1167 : Base(BOOST_MOVE_BASE(Base, x)) |
1148 {} | 1168 {} |
1149 | 1169 |
1150 treap& operator=(BOOST_RV_REF(treap) x) | 1170 treap& operator=(BOOST_RV_REF(treap) x) |
1151 { return static_cast<treap&>(this->Base::operator=(::boost::move(static_cast<Base&>(x)))); } | 1171 { return static_cast<treap&>(this->Base::operator=(BOOST_MOVE_BASE(Base, x))); } |
1152 | 1172 |
1153 static treap &container_from_end_iterator(iterator end_iterator) | 1173 static treap &container_from_end_iterator(iterator end_iterator) |
1154 { return static_cast<treap &>(Base::container_from_end_iterator(end_iterator)); } | 1174 { return static_cast<treap &>(Base::container_from_end_iterator(end_iterator)); } |
1155 | 1175 |
1156 static const treap &container_from_end_iterator(const_iterator end_iterator) | 1176 static const treap &container_from_end_iterator(const_iterator end_iterator) |