File indexing completed on 2025-01-30 09:44:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_INTRUSIVE_TREAP_SET_HPP
0013 #define BOOST_INTRUSIVE_TREAP_SET_HPP
0014
0015 #include <boost/intrusive/detail/config_begin.hpp>
0016 #include <boost/intrusive/intrusive_fwd.hpp>
0017 #include <boost/intrusive/treap.hpp>
0018 #include <boost/intrusive/detail/mpl.hpp>
0019 #include <boost/move/utility_core.hpp>
0020 #include <boost/static_assert.hpp>
0021
0022 #if defined(BOOST_HAS_PRAGMA_ONCE)
0023 # pragma once
0024 #endif
0025
0026 namespace boost {
0027 namespace intrusive {
0028
0029 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
0030 template<class ValueTraits, class VoidOrKeyOfValue, class VoidOrKeyComp, class VoidOrPrioOfValue, class VoidOrPrioComp, class SizeType, bool ConstantTimeSize, typename HeaderHolder>
0031 class treap_multiset_impl;
0032 #endif
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
0046 template<class T, class ...Options>
0047 #else
0048 template<class ValueTraits, class VoidOrKeyOfValue, class VoidOrKeyComp, class VoidOrPrioOfValue, class VoidOrPrioComp, class SizeType, bool ConstantTimeSize, typename HeaderHolder>
0049 #endif
0050 class treap_set_impl
0051 #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
0052 : public treap_impl<ValueTraits, VoidOrKeyOfValue, VoidOrKeyComp, VoidOrPrioOfValue, VoidOrPrioComp, SizeType, ConstantTimeSize, HeaderHolder>
0053 #endif
0054 {
0055
0056 public:
0057 typedef treap_impl<ValueTraits, VoidOrKeyOfValue, VoidOrKeyComp, VoidOrPrioOfValue, VoidOrPrioComp, SizeType, ConstantTimeSize, HeaderHolder> tree_type;
0058 BOOST_MOVABLE_BUT_NOT_COPYABLE(treap_set_impl)
0059
0060 typedef tree_type implementation_defined;
0061
0062
0063 public:
0064 typedef typename implementation_defined::value_type value_type;
0065 typedef typename implementation_defined::value_traits value_traits;
0066 typedef typename implementation_defined::key_type key_type;
0067 typedef typename implementation_defined::key_of_value key_of_value;
0068 typedef typename implementation_defined::pointer pointer;
0069 typedef typename implementation_defined::const_pointer const_pointer;
0070 typedef typename implementation_defined::reference reference;
0071 typedef typename implementation_defined::const_reference const_reference;
0072 typedef typename implementation_defined::difference_type difference_type;
0073 typedef typename implementation_defined::size_type size_type;
0074 typedef typename implementation_defined::value_compare value_compare;
0075 typedef typename implementation_defined::key_compare key_compare;
0076 typedef typename implementation_defined::priority_type priority_type;
0077 typedef typename implementation_defined::priority_compare priority_compare;
0078 typedef typename implementation_defined::iterator iterator;
0079 typedef typename implementation_defined::const_iterator const_iterator;
0080 typedef typename implementation_defined::reverse_iterator reverse_iterator;
0081 typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator;
0082 typedef typename implementation_defined::insert_commit_data insert_commit_data;
0083 typedef typename implementation_defined::node_traits node_traits;
0084 typedef typename implementation_defined::node node;
0085 typedef typename implementation_defined::node_ptr node_ptr;
0086 typedef typename implementation_defined::const_node_ptr const_node_ptr;
0087 typedef typename implementation_defined::node_algorithms node_algorithms;
0088
0089 static const bool constant_time_size = implementation_defined::constant_time_size;
0090
0091 public:
0092
0093 treap_set_impl()
0094 : tree_type()
0095 {}
0096
0097
0098 explicit treap_set_impl( const key_compare &cmp
0099 , const priority_compare &pcmp = priority_compare()
0100 , const value_traits &v_traits = value_traits())
0101 : tree_type(cmp, pcmp, v_traits)
0102 {}
0103
0104
0105 template<class Iterator>
0106 treap_set_impl( Iterator b, Iterator e
0107 , const key_compare &cmp = key_compare()
0108 , const priority_compare &pcmp = priority_compare()
0109 , const value_traits &v_traits = value_traits())
0110 : tree_type(true, b, e, cmp, pcmp, v_traits)
0111 {}
0112
0113
0114
0115 treap_set_impl(BOOST_RV_REF(treap_set_impl) x)
0116 : tree_type(BOOST_MOVE_BASE(tree_type, x))
0117 {}
0118
0119
0120
0121 treap_set_impl& operator=(BOOST_RV_REF(treap_set_impl) x)
0122 { return static_cast<treap_set_impl&>(tree_type::operator=(BOOST_MOVE_BASE(tree_type, x))); }
0123
0124 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
0125
0126 ~treap_set_impl();
0127
0128
0129 iterator begin() BOOST_NOEXCEPT;
0130
0131
0132 const_iterator begin() const BOOST_NOEXCEPT;
0133
0134
0135 const_iterator cbegin() const BOOST_NOEXCEPT;
0136
0137
0138 iterator end() BOOST_NOEXCEPT;
0139
0140
0141 const_iterator end() const BOOST_NOEXCEPT;
0142
0143
0144 const_iterator cend() const BOOST_NOEXCEPT;
0145
0146
0147 reverse_iterator rbegin() BOOST_NOEXCEPT;
0148
0149
0150 const_reverse_iterator rbegin() const BOOST_NOEXCEPT;
0151
0152
0153 const_reverse_iterator crbegin() const BOOST_NOEXCEPT;
0154
0155
0156 reverse_iterator rend() BOOST_NOEXCEPT;
0157
0158
0159 const_reverse_iterator rend() const BOOST_NOEXCEPT;
0160
0161
0162 const_reverse_iterator crend() const BOOST_NOEXCEPT;
0163
0164
0165 iterator root() BOOST_NOEXCEPT;
0166
0167
0168 const_iterator root() const BOOST_NOEXCEPT;
0169
0170
0171 const_iterator croot() const BOOST_NOEXCEPT;
0172
0173
0174 static treap_set_impl &container_from_end_iterator(iterator end_iterator) BOOST_NOEXCEPT;
0175
0176
0177 static const treap_set_impl &container_from_end_iterator(const_iterator end_iterator) BOOST_NOEXCEPT;
0178
0179
0180 static treap_set_impl &container_from_iterator(iterator it) BOOST_NOEXCEPT;
0181
0182
0183 static const treap_set_impl &container_from_iterator(const_iterator it) BOOST_NOEXCEPT;
0184
0185
0186 key_compare key_comp() const;
0187
0188
0189 value_compare value_comp() const;
0190
0191
0192 bool empty() const BOOST_NOEXCEPT;
0193
0194
0195 size_type size() const BOOST_NOEXCEPT;
0196
0197
0198 void swap(treap_set_impl& other);
0199
0200
0201 template <class Cloner, class Disposer>
0202 void clone_from(const treap_set_impl &src, Cloner cloner, Disposer disposer);
0203
0204 #else
0205
0206 using tree_type::clone_from;
0207
0208 #endif
0209
0210
0211 template <class Cloner, class Disposer>
0212 void clone_from(BOOST_RV_REF(treap_set_impl) src, Cloner cloner, Disposer disposer)
0213 { tree_type::clone_from(BOOST_MOVE_BASE(tree_type, src), cloner, disposer); }
0214
0215 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
0216
0217
0218 BOOST_INTRUSIVE_FORCEINLINE iterator top() BOOST_NOEXCEPT;
0219
0220
0221 BOOST_INTRUSIVE_FORCEINLINE const_iterator top() const BOOST_NOEXCEPT;
0222
0223
0224 BOOST_INTRUSIVE_FORCEINLINE const_iterator ctop() const BOOST_NOEXCEPT;
0225
0226
0227 BOOST_INTRUSIVE_FORCEINLINE reverse_iterator rtop() BOOST_NOEXCEPT;
0228
0229
0230 BOOST_INTRUSIVE_FORCEINLINE const_reverse_iterator rtop() const BOOST_NOEXCEPT;
0231
0232
0233 BOOST_INTRUSIVE_FORCEINLINE const_reverse_iterator crtop() const BOOST_NOEXCEPT;
0234
0235
0236 priority_compare priority_comp() const;
0237 #endif
0238
0239
0240 std::pair<iterator, bool> insert(reference value)
0241 { return tree_type::insert_unique(value); }
0242
0243
0244 iterator insert(const_iterator hint, reference value)
0245 { return tree_type::insert_unique(hint, value); }
0246
0247
0248 std::pair<iterator, bool> insert_check( const key_type &key, const priority_type &prio, insert_commit_data &commit_data)
0249 { return tree_type::insert_unique_check(key, prio, commit_data); }
0250
0251
0252 std::pair<iterator, bool> insert_check
0253 ( const_iterator hint, const key_type &key, const priority_type &prio, insert_commit_data &commit_data)
0254 { return tree_type::insert_unique_check(hint, key, prio, commit_data); }
0255
0256
0257 template<class KeyType, class KeyTypeKeyCompare, class PrioType, class PrioValuePrioCompare>
0258 std::pair<iterator, bool> insert_check
0259 ( const KeyType &key, KeyTypeKeyCompare comp, const PrioType &prio, PrioValuePrioCompare pcomp
0260 , insert_commit_data &commit_data)
0261 { return tree_type::insert_unique_check(key, comp, prio, pcomp, commit_data); }
0262
0263
0264 template<class KeyType, class KeyTypeKeyCompare, class PrioType, class PrioValuePrioCompare>
0265 std::pair<iterator, bool> insert_check
0266 ( const_iterator hint
0267 , const KeyType &key, KeyTypeKeyCompare comp
0268 , const PrioType &prio, PrioValuePrioCompare pcomp
0269 , insert_commit_data &commit_data)
0270 { return tree_type::insert_unique_check(hint, key, comp, prio, pcomp, commit_data); }
0271
0272
0273 template<class Iterator>
0274 void insert(Iterator b, Iterator e)
0275 { tree_type::insert_unique(b, e); }
0276
0277
0278 iterator insert_commit(reference value, const insert_commit_data &commit_data) BOOST_NOEXCEPT
0279 { return tree_type::insert_unique_commit(value, commit_data); }
0280
0281 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
0282
0283 iterator insert_before(const_iterator pos, reference value) BOOST_NOEXCEPT;
0284
0285
0286 void push_back(reference value) BOOST_NOEXCEPT;
0287
0288
0289 void push_front(reference value) BOOST_NOEXCEPT;
0290
0291
0292 iterator erase(const_iterator i) BOOST_NOEXCEPT;
0293
0294
0295 iterator erase(const_iterator b, const_iterator e) BOOST_NOEXCEPT;
0296
0297
0298 size_type erase(const key_type &key);
0299
0300
0301 template<class KeyType, class KeyTypeKeyCompare>
0302 size_type erase(const KeyType& key, KeyTypeKeyCompare comp);
0303
0304
0305 template<class Disposer>
0306 iterator erase_and_dispose(const_iterator i, Disposer disposer) BOOST_NOEXCEPT;
0307
0308
0309 template<class Disposer>
0310 iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) BOOST_NOEXCEPT;
0311
0312
0313 template<class Disposer>
0314 size_type erase_and_dispose(const key_type &key, Disposer disposer);
0315
0316
0317 template<class KeyType, class KeyTypeKeyCompare, class Disposer>
0318 size_type erase_and_dispose(const KeyType& key, KeyTypeKeyCompare comp, Disposer disposer);
0319
0320
0321 void clear() BOOST_NOEXCEPT;
0322
0323
0324 template<class Disposer>
0325 void clear_and_dispose(Disposer disposer) BOOST_NOEXCEPT;
0326
0327 #endif
0328
0329
0330 size_type count(const key_type &key) const
0331 { return static_cast<size_type>(this->tree_type::find(key) != this->tree_type::cend()); }
0332
0333
0334 template<class KeyType, class KeyTypeKeyCompare>
0335 size_type count(const KeyType& key, KeyTypeKeyCompare comp) const
0336 { return static_cast<size_type>(this->tree_type::find(key, comp) != this->tree_type::cend()); }
0337
0338 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
0339
0340
0341 iterator lower_bound(const key_type &key);
0342
0343
0344 template<class KeyType, class KeyTypeKeyCompare>
0345 iterator lower_bound(const KeyType& key, KeyTypeKeyCompare comp);
0346
0347
0348 const_iterator lower_bound(const key_type &key) const;
0349
0350
0351 template<class KeyType, class KeyTypeKeyCompare>
0352 const_iterator lower_bound(const KeyType& key, KeyTypeKeyCompare comp) const;
0353
0354
0355 iterator upper_bound(const key_type &key);
0356
0357
0358 template<class KeyType, class KeyTypeKeyCompare>
0359 iterator upper_bound(const KeyType& key, KeyTypeKeyCompare comp);
0360
0361
0362 const_iterator upper_bound(const key_type &key) const;
0363
0364
0365 template<class KeyType, class KeyTypeKeyCompare>
0366 const_iterator upper_bound(const KeyType& key, KeyTypeKeyCompare comp) const;
0367
0368
0369 iterator find(const key_type &key);
0370
0371
0372 template<class KeyType, class KeyTypeKeyCompare>
0373 iterator find(const KeyType& key, KeyTypeKeyCompare comp);
0374
0375
0376 const_iterator find(const key_type &key) const;
0377
0378
0379 template<class KeyType, class KeyTypeKeyCompare>
0380 const_iterator find(const KeyType& key, KeyTypeKeyCompare comp) const;
0381
0382 #endif
0383
0384
0385 std::pair<iterator,iterator> equal_range(const key_type &key)
0386 { return this->tree_type::lower_bound_range(key); }
0387
0388
0389 template<class KeyType, class KeyTypeKeyCompare>
0390 std::pair<iterator,iterator> equal_range(const KeyType& key, KeyTypeKeyCompare comp)
0391 { return this->tree_type::equal_range(key, comp); }
0392
0393
0394 std::pair<const_iterator, const_iterator>
0395 equal_range(const key_type &key) const
0396 { return this->tree_type::lower_bound_range(key); }
0397
0398
0399 template<class KeyType, class KeyTypeKeyCompare>
0400 std::pair<const_iterator, const_iterator>
0401 equal_range(const KeyType& key, KeyTypeKeyCompare comp) const
0402 { return this->tree_type::equal_range(key, comp); }
0403
0404 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
0405
0406
0407 std::pair<iterator,iterator> bounded_range
0408 (const key_type &lower_key, const key_type &upper_key, bool left_closed, bool right_closed);
0409
0410
0411 template<class KeyType, class KeyTypeKeyCompare>
0412 std::pair<iterator,iterator> bounded_range
0413 (const KeyType& lower_key, const KeyType& upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed);
0414
0415
0416 std::pair<const_iterator, const_iterator>
0417 bounded_range(const key_type &lower_key, const key_type &upper_key, bool left_closed, bool right_closed) const;
0418
0419
0420 template<class KeyType, class KeyTypeKeyCompare>
0421 std::pair<const_iterator, const_iterator> bounded_range
0422 (const KeyType& lower_key, const KeyType& upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed) const;
0423
0424
0425 static iterator s_iterator_to(reference value) BOOST_NOEXCEPT;
0426
0427
0428 static const_iterator s_iterator_to(const_reference value) BOOST_NOEXCEPT;
0429
0430
0431 iterator iterator_to(reference value) BOOST_NOEXCEPT;
0432
0433
0434 const_iterator iterator_to(const_reference value) const BOOST_NOEXCEPT;
0435
0436
0437 static void init_node(reference value) BOOST_NOEXCEPT;
0438
0439
0440 pointer unlink_leftmost_without_rebalance() BOOST_NOEXCEPT;
0441
0442
0443 void replace_node(iterator replace_this, reference with_this) BOOST_NOEXCEPT;
0444
0445
0446 void remove_node(reference value) BOOST_NOEXCEPT;
0447
0448
0449
0450 template<class ...Options2>
0451 void merge(treap_set<T, Options2...> &source);
0452
0453
0454 template<class ...Options2>
0455 void merge(treap_multiset<T, Options2...> &source);
0456
0457 #else
0458
0459 template<class Compare2>
0460 void merge(treap_set_impl<ValueTraits, VoidOrKeyOfValue, Compare2, VoidOrPrioOfValue, VoidOrPrioComp, SizeType, ConstantTimeSize, HeaderHolder> &source)
0461 { return tree_type::merge_unique(source); }
0462
0463 template<class Compare2>
0464 void merge(treap_multiset_impl<ValueTraits, VoidOrKeyOfValue, Compare2, VoidOrPrioOfValue, VoidOrPrioComp, SizeType, ConstantTimeSize, HeaderHolder> &source)
0465 { return tree_type::merge_unique(source); }
0466
0467 #endif
0468 };
0469
0470
0471
0472
0473 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0474 template<class T, class ...Options>
0475 #else
0476 template<class T, class O1 = void, class O2 = void
0477 , class O3 = void, class O4 = void
0478 , class O5 = void, class O6 = void
0479 , class O7 = void>
0480 #endif
0481 struct make_treap_set
0482 {
0483 typedef typename pack_options
0484 < treap_defaults,
0485 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0486 O1, O2, O3, O4, O5, O6, O7
0487 #else
0488 Options...
0489 #endif
0490 >::type packed_options;
0491
0492 typedef typename detail::get_value_traits
0493 <T, typename packed_options::proto_value_traits>::type value_traits;
0494
0495 typedef treap_set_impl
0496 < value_traits
0497 , typename packed_options::key_of_value
0498 , typename packed_options::compare
0499 , typename packed_options::priority_of_value
0500 , typename packed_options::priority
0501 , typename packed_options::size_type
0502 , packed_options::constant_time_size
0503 , typename packed_options::header_holder_type
0504 > implementation_defined;
0505
0506 typedef implementation_defined type;
0507 };
0508
0509 #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
0510
0511 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0512 template<class T, class O1, class O2, class O3, class O4, class O5, class O6, class O7>
0513 #else
0514 template<class T, class ...Options>
0515 #endif
0516 class treap_set
0517 : public make_treap_set<T,
0518 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0519 O1, O2, O3, O4, O5, O6, O7
0520 #else
0521 Options...
0522 #endif
0523 >::type
0524 {
0525 typedef typename make_treap_set
0526 <T,
0527 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0528 O1, O2, O3, O4, O5, O6, O7
0529 #else
0530 Options...
0531 #endif
0532 >::type Base;
0533 BOOST_MOVABLE_BUT_NOT_COPYABLE(treap_set)
0534
0535 public:
0536 typedef typename Base::key_compare key_compare;
0537 typedef typename Base::priority_compare priority_compare;
0538 typedef typename Base::value_traits value_traits;
0539 typedef typename Base::iterator iterator;
0540 typedef typename Base::const_iterator const_iterator;
0541
0542
0543 BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value));
0544
0545 BOOST_INTRUSIVE_FORCEINLINE treap_set()
0546 : Base()
0547 {}
0548
0549 BOOST_INTRUSIVE_FORCEINLINE explicit treap_set( const key_compare &cmp
0550 , const priority_compare &pcmp = priority_compare()
0551 , const value_traits &v_traits = value_traits())
0552 : Base(cmp, pcmp, v_traits)
0553 {}
0554
0555 template<class Iterator>
0556 BOOST_INTRUSIVE_FORCEINLINE treap_set( Iterator b, Iterator e
0557 , const key_compare &cmp = key_compare()
0558 , const priority_compare &pcmp = priority_compare()
0559 , const value_traits &v_traits = value_traits())
0560 : Base(b, e, cmp, pcmp, v_traits)
0561 {}
0562
0563 BOOST_INTRUSIVE_FORCEINLINE treap_set(BOOST_RV_REF(treap_set) x)
0564 : Base(BOOST_MOVE_BASE(Base, x))
0565 {}
0566
0567 BOOST_INTRUSIVE_FORCEINLINE treap_set& operator=(BOOST_RV_REF(treap_set) x)
0568 { return static_cast<treap_set &>(this->Base::operator=(BOOST_MOVE_BASE(Base, x))); }
0569
0570 template <class Cloner, class Disposer>
0571 BOOST_INTRUSIVE_FORCEINLINE void clone_from(const treap_set &src, Cloner cloner, Disposer disposer)
0572 { Base::clone_from(src, cloner, disposer); }
0573
0574 template <class Cloner, class Disposer>
0575 BOOST_INTRUSIVE_FORCEINLINE void clone_from(BOOST_RV_REF(treap_set) src, Cloner cloner, Disposer disposer)
0576 { Base::clone_from(BOOST_MOVE_BASE(Base, src), cloner, disposer); }
0577
0578 BOOST_INTRUSIVE_FORCEINLINE static treap_set &container_from_end_iterator(iterator end_iterator) BOOST_NOEXCEPT
0579 { return static_cast<treap_set &>(Base::container_from_end_iterator(end_iterator)); }
0580
0581 BOOST_INTRUSIVE_FORCEINLINE static const treap_set &container_from_end_iterator(const_iterator end_iterator) BOOST_NOEXCEPT
0582 { return static_cast<const treap_set &>(Base::container_from_end_iterator(end_iterator)); }
0583
0584 BOOST_INTRUSIVE_FORCEINLINE static treap_set &container_from_iterator(iterator it) BOOST_NOEXCEPT
0585 { return static_cast<treap_set &>(Base::container_from_iterator(it)); }
0586
0587 BOOST_INTRUSIVE_FORCEINLINE static const treap_set &container_from_iterator(const_iterator it) BOOST_NOEXCEPT
0588 { return static_cast<const treap_set &>(Base::container_from_iterator(it)); }
0589 };
0590
0591 #endif
0592
0593
0594
0595
0596
0597
0598
0599
0600
0601
0602
0603
0604 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
0605 template<class T, class ...Options>
0606 #else
0607 template<class ValueTraits, class VoidOrKeyOfValue, class VoidOrKeyComp, class VoidOrPrioOfValue, class VoidOrPrioComp, class SizeType, bool ConstantTimeSize, typename HeaderHolder>
0608 #endif
0609 class treap_multiset_impl
0610 #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
0611 : public treap_impl<ValueTraits, VoidOrKeyOfValue, VoidOrKeyComp, VoidOrPrioOfValue, VoidOrPrioComp, SizeType, ConstantTimeSize, HeaderHolder>
0612 #endif
0613 {
0614
0615 typedef treap_impl<ValueTraits, VoidOrKeyOfValue, VoidOrKeyComp, VoidOrPrioOfValue, VoidOrPrioComp, SizeType, ConstantTimeSize, HeaderHolder> tree_type;
0616 BOOST_MOVABLE_BUT_NOT_COPYABLE(treap_multiset_impl)
0617
0618 typedef tree_type implementation_defined;
0619
0620
0621 public:
0622 typedef typename implementation_defined::value_type value_type;
0623 typedef typename implementation_defined::value_traits value_traits;
0624 typedef typename implementation_defined::key_type key_type;
0625 typedef typename implementation_defined::key_of_value key_of_value;
0626 typedef typename implementation_defined::pointer pointer;
0627 typedef typename implementation_defined::const_pointer const_pointer;
0628 typedef typename implementation_defined::reference reference;
0629 typedef typename implementation_defined::const_reference const_reference;
0630 typedef typename implementation_defined::difference_type difference_type;
0631 typedef typename implementation_defined::size_type size_type;
0632 typedef typename implementation_defined::value_compare value_compare;
0633 typedef typename implementation_defined::key_compare key_compare;
0634 typedef typename implementation_defined::priority_type priority_type;
0635 typedef typename implementation_defined::priority_compare priority_compare;
0636 typedef typename implementation_defined::iterator iterator;
0637 typedef typename implementation_defined::const_iterator const_iterator;
0638 typedef typename implementation_defined::reverse_iterator reverse_iterator;
0639 typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator;
0640 typedef typename implementation_defined::insert_commit_data insert_commit_data;
0641 typedef typename implementation_defined::node_traits node_traits;
0642 typedef typename implementation_defined::node node;
0643 typedef typename implementation_defined::node_ptr node_ptr;
0644 typedef typename implementation_defined::const_node_ptr const_node_ptr;
0645 typedef typename implementation_defined::node_algorithms node_algorithms;
0646
0647 static const bool constant_time_size = implementation_defined::constant_time_size;
0648
0649 public:
0650
0651
0652 treap_multiset_impl()
0653 : tree_type()
0654 {}
0655
0656
0657 explicit treap_multiset_impl( const key_compare &cmp
0658 , const priority_compare &pcmp = priority_compare()
0659 , const value_traits &v_traits = value_traits())
0660 : tree_type(cmp, pcmp, v_traits)
0661 {}
0662
0663
0664 template<class Iterator>
0665 treap_multiset_impl( Iterator b, Iterator e
0666 , const key_compare &cmp = key_compare()
0667 , const priority_compare &pcmp = priority_compare()
0668 , const value_traits &v_traits = value_traits())
0669 : tree_type(false, b, e, cmp, pcmp, v_traits)
0670 {}
0671
0672
0673
0674 treap_multiset_impl(BOOST_RV_REF(treap_multiset_impl) x)
0675 : tree_type(BOOST_MOVE_BASE(tree_type, x))
0676 {}
0677
0678
0679
0680 treap_multiset_impl& operator=(BOOST_RV_REF(treap_multiset_impl) x)
0681 { return static_cast<treap_multiset_impl&>(tree_type::operator=(BOOST_MOVE_BASE(tree_type, x))); }
0682
0683 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
0684
0685 ~treap_multiset_impl();
0686
0687
0688 iterator begin() BOOST_NOEXCEPT;
0689
0690
0691 const_iterator begin() const BOOST_NOEXCEPT;
0692
0693
0694 const_iterator cbegin() const BOOST_NOEXCEPT;
0695
0696
0697 iterator end() BOOST_NOEXCEPT;
0698
0699
0700 const_iterator end() const BOOST_NOEXCEPT;
0701
0702
0703 const_iterator cend() const BOOST_NOEXCEPT;
0704
0705
0706 reverse_iterator rbegin() BOOST_NOEXCEPT;
0707
0708
0709 const_reverse_iterator rbegin() const BOOST_NOEXCEPT;
0710
0711
0712 const_reverse_iterator crbegin() const BOOST_NOEXCEPT;
0713
0714
0715 reverse_iterator rend() BOOST_NOEXCEPT;
0716
0717
0718 const_reverse_iterator rend() const BOOST_NOEXCEPT;
0719
0720
0721 const_reverse_iterator crend() const BOOST_NOEXCEPT;
0722
0723
0724 iterator root() BOOST_NOEXCEPT;
0725
0726
0727 const_iterator root() const BOOST_NOEXCEPT;
0728
0729
0730 const_iterator croot() const BOOST_NOEXCEPT;
0731
0732
0733 static treap_multiset_impl &container_from_end_iterator(iterator end_iterator) BOOST_NOEXCEPT;
0734
0735
0736 static const treap_multiset_impl &container_from_end_iterator(const_iterator end_iterator) BOOST_NOEXCEPT;
0737
0738
0739 static treap_multiset_impl &container_from_iterator(iterator it) BOOST_NOEXCEPT;
0740
0741
0742 static const treap_multiset_impl &container_from_iterator(const_iterator it) BOOST_NOEXCEPT;
0743
0744
0745 key_compare key_comp() const;
0746
0747
0748 value_compare value_comp() const;
0749
0750
0751 bool empty() const BOOST_NOEXCEPT;
0752
0753
0754 size_type size() const BOOST_NOEXCEPT;
0755
0756
0757 void swap(treap_multiset_impl& other);
0758
0759
0760 template <class Cloner, class Disposer>
0761 void clone_from(const treap_multiset_impl &src, Cloner cloner, Disposer disposer);
0762
0763 #else
0764
0765 using tree_type::clone_from;
0766
0767 #endif
0768
0769
0770 template <class Cloner, class Disposer>
0771 void clone_from(BOOST_RV_REF(treap_multiset_impl) src, Cloner cloner, Disposer disposer)
0772 { tree_type::clone_from(BOOST_MOVE_BASE(tree_type, src), cloner, disposer); }
0773
0774 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
0775
0776
0777 BOOST_INTRUSIVE_FORCEINLINE iterator top() BOOST_NOEXCEPT;
0778
0779
0780 BOOST_INTRUSIVE_FORCEINLINE const_iterator top() const BOOST_NOEXCEPT;
0781
0782
0783 BOOST_INTRUSIVE_FORCEINLINE const_iterator ctop() const BOOST_NOEXCEPT;
0784
0785
0786 BOOST_INTRUSIVE_FORCEINLINE reverse_iterator rtop() BOOST_NOEXCEPT;
0787
0788
0789 BOOST_INTRUSIVE_FORCEINLINE const_reverse_iterator rtop() const BOOST_NOEXCEPT;
0790
0791
0792 BOOST_INTRUSIVE_FORCEINLINE const_reverse_iterator crtop() const BOOST_NOEXCEPT;
0793
0794
0795 priority_compare priority_comp() const;
0796 #endif
0797
0798
0799 iterator insert(reference value)
0800 { return tree_type::insert_equal(value); }
0801
0802
0803 iterator insert(const_iterator hint, reference value)
0804 { return tree_type::insert_equal(hint, value); }
0805
0806
0807 template<class Iterator>
0808 void insert(Iterator b, Iterator e)
0809 { tree_type::insert_equal(b, e); }
0810
0811 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
0812
0813 iterator insert_before(const_iterator pos, reference value) BOOST_NOEXCEPT;
0814
0815
0816 void push_back(reference value) BOOST_NOEXCEPT;
0817
0818
0819 void push_front(reference value) BOOST_NOEXCEPT;
0820
0821
0822 iterator erase(const_iterator i) BOOST_NOEXCEPT;
0823
0824
0825 iterator erase(const_iterator b, const_iterator e) BOOST_NOEXCEPT;
0826
0827
0828 size_type erase(const key_type &key);
0829
0830
0831 template<class KeyType, class KeyTypeKeyCompare>
0832 size_type erase(const KeyType& key, KeyTypeKeyCompare comp);
0833
0834
0835 template<class Disposer>
0836 iterator erase_and_dispose(const_iterator i, Disposer disposer) BOOST_NOEXCEPT;
0837
0838
0839 template<class Disposer>
0840 iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) BOOST_NOEXCEPT;
0841
0842
0843 template<class Disposer>
0844 size_type erase_and_dispose(const key_type &key, Disposer disposer);
0845
0846
0847 template<class KeyType, class KeyTypeKeyCompare, class Disposer>
0848 size_type erase_and_dispose(const KeyType& key, KeyTypeKeyCompare comp, Disposer disposer);
0849
0850
0851 void clear() BOOST_NOEXCEPT;
0852
0853
0854 template<class Disposer>
0855 void clear_and_dispose(Disposer disposer) BOOST_NOEXCEPT;
0856
0857
0858 size_type count(const key_type &key) const;
0859
0860
0861 template<class KeyType, class KeyTypeKeyCompare>
0862 size_type count(const KeyType& key, KeyTypeKeyCompare comp) const;
0863
0864
0865 iterator lower_bound(const key_type &key);
0866
0867
0868 template<class KeyType, class KeyTypeKeyCompare>
0869 iterator lower_bound(const KeyType& key, KeyTypeKeyCompare comp);
0870
0871
0872 const_iterator lower_bound(const key_type &key) const;
0873
0874
0875 template<class KeyType, class KeyTypeKeyCompare>
0876 const_iterator lower_bound(const KeyType& key, KeyTypeKeyCompare comp) const;
0877
0878
0879 iterator upper_bound(const key_type &key);
0880
0881
0882 template<class KeyType, class KeyTypeKeyCompare>
0883 iterator upper_bound(const KeyType& key, KeyTypeKeyCompare comp);
0884
0885
0886 const_iterator upper_bound(const key_type &key) const;
0887
0888
0889 template<class KeyType, class KeyTypeKeyCompare>
0890 const_iterator upper_bound(const KeyType& key, KeyTypeKeyCompare comp) const;
0891
0892
0893 iterator find(const key_type &key);
0894
0895
0896 template<class KeyType, class KeyTypeKeyCompare>
0897 iterator find(const KeyType& key, KeyTypeKeyCompare comp);
0898
0899
0900 const_iterator find(const key_type &key) const;
0901
0902
0903 template<class KeyType, class KeyTypeKeyCompare>
0904 const_iterator find(const KeyType& key, KeyTypeKeyCompare comp) const;
0905
0906
0907 std::pair<iterator,iterator> equal_range(const key_type &key);
0908
0909
0910 template<class KeyType, class KeyTypeKeyCompare>
0911 std::pair<iterator,iterator> equal_range(const KeyType& key, KeyTypeKeyCompare comp);
0912
0913
0914 std::pair<const_iterator, const_iterator>
0915 equal_range(const key_type &key) const;
0916
0917
0918 template<class KeyType, class KeyTypeKeyCompare>
0919 std::pair<const_iterator, const_iterator>
0920 equal_range(const KeyType& key, KeyTypeKeyCompare comp) const;
0921
0922
0923 std::pair<iterator,iterator> bounded_range
0924 (const key_type &lower_key, const key_type &upper_key, bool left_closed, bool right_closed);
0925
0926
0927 template<class KeyType, class KeyTypeKeyCompare>
0928 std::pair<iterator,iterator> bounded_range
0929 (const KeyType& lower_key, const KeyType& upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed);
0930
0931
0932 std::pair<const_iterator, const_iterator>
0933 bounded_range(const key_type &lower_key, const key_type &upper_key, bool left_closed, bool right_closed) const;
0934
0935
0936 template<class KeyType, class KeyTypeKeyCompare>
0937 std::pair<const_iterator, const_iterator> bounded_range
0938 (const KeyType& lower_key, const KeyType& upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed) const;
0939
0940
0941 static iterator s_iterator_to(reference value) BOOST_NOEXCEPT;
0942
0943
0944 static const_iterator s_iterator_to(const_reference value) BOOST_NOEXCEPT;
0945
0946
0947 iterator iterator_to(reference value) BOOST_NOEXCEPT;
0948
0949
0950 const_iterator iterator_to(const_reference value) const BOOST_NOEXCEPT;
0951
0952
0953 static void init_node(reference value) BOOST_NOEXCEPT;
0954
0955
0956 pointer unlink_leftmost_without_rebalance() BOOST_NOEXCEPT;
0957
0958
0959 void replace_node(iterator replace_this, reference with_this) BOOST_NOEXCEPT;
0960
0961
0962 void remove_node(reference value) BOOST_NOEXCEPT;
0963
0964
0965 template<class ...Options2>
0966 void merge(treap_multiset<T, Options2...> &source);
0967
0968
0969 template<class ...Options2>
0970 void merge(treap_set<T, Options2...> &source);
0971
0972 #else
0973
0974 template<class Compare2>
0975 void merge(treap_multiset_impl<ValueTraits, VoidOrKeyOfValue, Compare2, VoidOrPrioOfValue, VoidOrPrioComp, SizeType, ConstantTimeSize, HeaderHolder> &source)
0976 { return tree_type::merge_equal(source); }
0977
0978 template<class Compare2>
0979 void merge(treap_set_impl<ValueTraits, VoidOrKeyOfValue, Compare2, VoidOrPrioOfValue, VoidOrPrioComp, SizeType, ConstantTimeSize, HeaderHolder> &source)
0980 { return tree_type::merge_equal(source); }
0981
0982 #endif
0983 };
0984
0985
0986
0987
0988 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0989 template<class T, class ...Options>
0990 #else
0991 template<class T, class O1 = void, class O2 = void
0992 , class O3 = void, class O4 = void
0993 , class O5 = void, class O6 = void
0994 , class O7 = void>
0995 #endif
0996 struct make_treap_multiset
0997 {
0998 typedef typename pack_options
0999 < treap_defaults,
1000 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
1001 O1, O2, O3, O4, O5, O6, O7
1002 #else
1003 Options...
1004 #endif
1005 >::type packed_options;
1006
1007 typedef typename detail::get_value_traits
1008 <T, typename packed_options::proto_value_traits>::type value_traits;
1009
1010 typedef treap_multiset_impl
1011 < value_traits
1012 , typename packed_options::key_of_value
1013 , typename packed_options::compare
1014 , typename packed_options::priority_of_value
1015 , typename packed_options::priority
1016 , typename packed_options::size_type
1017 , packed_options::constant_time_size
1018 , typename packed_options::header_holder_type
1019 > implementation_defined;
1020
1021 typedef implementation_defined type;
1022 };
1023
1024 #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
1025
1026 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
1027 template<class T, class O1, class O2, class O3, class O4, class O5, class O6, class O7>
1028 #else
1029 template<class T, class ...Options>
1030 #endif
1031 class treap_multiset
1032 : public make_treap_multiset<T,
1033 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
1034 O1, O2, O3, O4, O5, O6, O7
1035 #else
1036 Options...
1037 #endif
1038 >::type
1039 {
1040 typedef typename make_treap_multiset
1041 <T,
1042 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
1043 O1, O2, O3, O4, O5, O6, O7
1044 #else
1045 Options...
1046 #endif
1047 >::type Base;
1048 BOOST_MOVABLE_BUT_NOT_COPYABLE(treap_multiset)
1049
1050 public:
1051 typedef typename Base::key_compare key_compare;
1052 typedef typename Base::priority_compare priority_compare;
1053 typedef typename Base::value_traits value_traits;
1054 typedef typename Base::iterator iterator;
1055 typedef typename Base::const_iterator const_iterator;
1056
1057
1058 BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value));
1059
1060 BOOST_INTRUSIVE_FORCEINLINE treap_multiset()
1061 : Base()
1062 {}
1063
1064 BOOST_INTRUSIVE_FORCEINLINE explicit treap_multiset( const key_compare &cmp
1065 , const priority_compare &pcmp = priority_compare()
1066 , const value_traits &v_traits = value_traits())
1067 : Base(cmp, pcmp, v_traits)
1068 {}
1069
1070 template<class Iterator>
1071 BOOST_INTRUSIVE_FORCEINLINE treap_multiset( Iterator b, Iterator e
1072 , const key_compare &cmp = key_compare()
1073 , const priority_compare &pcmp = priority_compare()
1074 , const value_traits &v_traits = value_traits())
1075 : Base(b, e, cmp, pcmp, v_traits)
1076 {}
1077
1078 BOOST_INTRUSIVE_FORCEINLINE treap_multiset(BOOST_RV_REF(treap_multiset) x)
1079 : Base(BOOST_MOVE_BASE(Base, x))
1080 {}
1081
1082 BOOST_INTRUSIVE_FORCEINLINE treap_multiset& operator=(BOOST_RV_REF(treap_multiset) x)
1083 { return static_cast<treap_multiset &>(this->Base::operator=(BOOST_MOVE_BASE(Base, x))); }
1084
1085 template <class Cloner, class Disposer>
1086 BOOST_INTRUSIVE_FORCEINLINE void clone_from(const treap_multiset &src, Cloner cloner, Disposer disposer)
1087 { Base::clone_from(src, cloner, disposer); }
1088
1089 template <class Cloner, class Disposer>
1090 BOOST_INTRUSIVE_FORCEINLINE void clone_from(BOOST_RV_REF(treap_multiset) src, Cloner cloner, Disposer disposer)
1091 { Base::clone_from(BOOST_MOVE_BASE(Base, src), cloner, disposer); }
1092
1093 BOOST_INTRUSIVE_FORCEINLINE static treap_multiset &container_from_end_iterator(iterator end_iterator) BOOST_NOEXCEPT
1094 { return static_cast<treap_multiset &>(Base::container_from_end_iterator(end_iterator)); }
1095
1096 BOOST_INTRUSIVE_FORCEINLINE static const treap_multiset &container_from_end_iterator(const_iterator end_iterator) BOOST_NOEXCEPT
1097 { return static_cast<const treap_multiset &>(Base::container_from_end_iterator(end_iterator)); }
1098
1099 BOOST_INTRUSIVE_FORCEINLINE static treap_multiset &container_from_iterator(iterator it) BOOST_NOEXCEPT
1100 { return static_cast<treap_multiset &>(Base::container_from_iterator(it)); }
1101
1102 BOOST_INTRUSIVE_FORCEINLINE static const treap_multiset &container_from_iterator(const_iterator it) BOOST_NOEXCEPT
1103 { return static_cast<const treap_multiset &>(Base::container_from_iterator(it)); }
1104 };
1105
1106 #endif
1107
1108 }
1109 }
1110
1111 #include <boost/intrusive/detail/config_end.hpp>
1112
1113 #endif