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