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