Brian Silverman | fad8f55 | 2018-08-04 23:36:19 -0700 | [diff] [blame^] | 1 | ////////////////////////////////////////////////////////////////////////////// |
| 2 | // |
| 3 | // (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost |
| 4 | // Software License, Version 1.0. (See accompanying file |
| 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 6 | // |
| 7 | // See http://www.boost.org/libs/container for documentation. |
| 8 | // |
| 9 | ////////////////////////////////////////////////////////////////////////////// |
| 10 | |
| 11 | #ifndef BOOST_CONTAINER_SET_HPP |
| 12 | #define BOOST_CONTAINER_SET_HPP |
| 13 | |
| 14 | #ifndef BOOST_CONFIG_HPP |
| 15 | # include <boost/config.hpp> |
| 16 | #endif |
| 17 | |
| 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) |
| 19 | # pragma once |
| 20 | #endif |
| 21 | |
| 22 | #include <boost/container/detail/config_begin.hpp> |
| 23 | #include <boost/container/detail/workaround.hpp> |
| 24 | // container |
| 25 | #include <boost/container/container_fwd.hpp> |
| 26 | // container/detail |
| 27 | #include <boost/container/detail/mpl.hpp> |
| 28 | #include <boost/container/detail/tree.hpp> |
| 29 | #include <boost/container/new_allocator.hpp> //new_allocator |
| 30 | // intrusive/detail |
| 31 | #include <boost/intrusive/detail/minimal_pair_header.hpp> //pair |
| 32 | #include <boost/intrusive/detail/minimal_less_equal_header.hpp>//less, equal |
| 33 | // move |
| 34 | #include <boost/move/traits.hpp> |
| 35 | #include <boost/move/utility_core.hpp> |
| 36 | // move/detail |
| 37 | #include <boost/move/detail/move_helpers.hpp> |
| 38 | #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) |
| 39 | #include <boost/move/detail/fwd_macros.hpp> |
| 40 | #endif |
| 41 | // std |
| 42 | #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) |
| 43 | #include <initializer_list> |
| 44 | #endif |
| 45 | |
| 46 | namespace boost { |
| 47 | namespace container { |
| 48 | |
| 49 | #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 50 | |
| 51 | //! A set is a kind of associative container that supports unique keys (contains at |
| 52 | //! most one of each key value) and provides for fast retrieval of the keys themselves. |
| 53 | //! Class set supports bidirectional iterators. |
| 54 | //! |
| 55 | //! A set satisfies all of the requirements of a container and of a reversible container |
| 56 | //! , and of an associative container. A set also provides most operations described in |
| 57 | //! for unique keys. |
| 58 | //! |
| 59 | //! \tparam Key is the type to be inserted in the set, which is also the key_type |
| 60 | //! \tparam Compare is the comparison functor used to order keys |
| 61 | //! \tparam Allocator is the allocator to be used to allocate memory for this container |
| 62 | //! \tparam Options is an packed option type generated using using boost::container::tree_assoc_options. |
| 63 | template <class Key, class Compare = std::less<Key>, class Allocator = new_allocator<Key>, class Options = void> |
| 64 | #else |
| 65 | template <class Key, class Compare, class Allocator, class Options> |
| 66 | #endif |
| 67 | class set |
| 68 | ///@cond |
| 69 | : public dtl::tree |
| 70 | < Key, dtl::identity<Key>, Compare, Allocator, Options> |
| 71 | ///@endcond |
| 72 | { |
| 73 | #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 74 | private: |
| 75 | BOOST_COPYABLE_AND_MOVABLE(set) |
| 76 | typedef dtl::tree |
| 77 | < Key, dtl::identity<Key>, Compare, Allocator, Options> base_t; |
| 78 | #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 79 | |
| 80 | public: |
| 81 | ////////////////////////////////////////////// |
| 82 | // |
| 83 | // types |
| 84 | // |
| 85 | ////////////////////////////////////////////// |
| 86 | typedef Key key_type; |
| 87 | typedef Key value_type; |
| 88 | typedef Compare key_compare; |
| 89 | typedef Compare value_compare; |
| 90 | typedef ::boost::container::allocator_traits<Allocator> allocator_traits_type; |
| 91 | typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer; |
| 92 | typedef typename ::boost::container::allocator_traits<Allocator>::const_pointer const_pointer; |
| 93 | typedef typename ::boost::container::allocator_traits<Allocator>::reference reference; |
| 94 | typedef typename ::boost::container::allocator_traits<Allocator>::const_reference const_reference; |
| 95 | typedef typename ::boost::container::allocator_traits<Allocator>::size_type size_type; |
| 96 | typedef typename ::boost::container::allocator_traits<Allocator>::difference_type difference_type; |
| 97 | typedef Allocator allocator_type; |
| 98 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type; |
| 99 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator; |
| 100 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator; |
| 101 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator; |
| 102 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator; |
| 103 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::node_type) node_type; |
| 104 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::insert_return_type) insert_return_type; |
| 105 | |
| 106 | ////////////////////////////////////////////// |
| 107 | // |
| 108 | // construct/copy/destroy |
| 109 | // |
| 110 | ////////////////////////////////////////////// |
| 111 | |
| 112 | //! <b>Effects</b>: Default constructs an empty set. |
| 113 | //! |
| 114 | //! <b>Complexity</b>: Constant. |
| 115 | |
| 116 | BOOST_CONTAINER_FORCEINLINE set() |
| 117 | BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible<Allocator>::value && |
| 118 | dtl::is_nothrow_default_constructible<Compare>::value) |
| 119 | : base_t() |
| 120 | {} |
| 121 | |
| 122 | //! <b>Effects</b>: Constructs an empty set using the specified allocator object. |
| 123 | //! |
| 124 | //! <b>Complexity</b>: Constant. |
| 125 | BOOST_CONTAINER_FORCEINLINE explicit set(const allocator_type& a) |
| 126 | : base_t(a) |
| 127 | {} |
| 128 | |
| 129 | //! <b>Effects</b>: Constructs an empty set using the specified comparison object. |
| 130 | //! |
| 131 | //! <b>Complexity</b>: Constant. |
| 132 | BOOST_CONTAINER_FORCEINLINE explicit set(const Compare& comp) |
| 133 | : base_t(comp) |
| 134 | {} |
| 135 | |
| 136 | //! <b>Effects</b>: Constructs an empty set using the specified comparison object |
| 137 | //! and allocator. |
| 138 | //! |
| 139 | //! <b>Complexity</b>: Constant. |
| 140 | BOOST_CONTAINER_FORCEINLINE set(const Compare& comp, const allocator_type& a) |
| 141 | : base_t(comp, a) |
| 142 | {} |
| 143 | |
| 144 | //! <b>Effects</b>: Constructs an empty set using and |
| 145 | //! inserts elements from the range [first ,last ). |
| 146 | //! |
| 147 | //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using |
| 148 | //! the predicate and otherwise N logN, where N is last - first. |
| 149 | template <class InputIterator> |
| 150 | BOOST_CONTAINER_FORCEINLINE set(InputIterator first, InputIterator last) |
| 151 | : base_t(true, first, last) |
| 152 | {} |
| 153 | |
| 154 | //! <b>Effects</b>: Constructs an empty set using the specified |
| 155 | //! allocator, and inserts elements from the range [first ,last ). |
| 156 | //! |
| 157 | //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using |
| 158 | //! the predicate and otherwise N logN, where N is last - first. |
| 159 | template <class InputIterator> |
| 160 | BOOST_CONTAINER_FORCEINLINE set(InputIterator first, InputIterator last, const allocator_type& a) |
| 161 | : base_t(true, first, last, key_compare(), a) |
| 162 | {} |
| 163 | |
| 164 | //! <b>Effects</b>: Constructs an empty set using the specified comparison object and |
| 165 | //! inserts elements from the range [first ,last ). |
| 166 | //! |
| 167 | //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using |
| 168 | //! the predicate and otherwise N logN, where N is last - first. |
| 169 | template <class InputIterator> |
| 170 | BOOST_CONTAINER_FORCEINLINE set(InputIterator first, InputIterator last, const Compare& comp) |
| 171 | : base_t(true, first, last, comp) |
| 172 | {} |
| 173 | |
| 174 | //! <b>Effects</b>: Constructs an empty set using the specified comparison object and |
| 175 | //! allocator, and inserts elements from the range [first ,last ). |
| 176 | //! |
| 177 | //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using |
| 178 | //! the predicate and otherwise N logN, where N is last - first. |
| 179 | template <class InputIterator> |
| 180 | BOOST_CONTAINER_FORCEINLINE set(InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a) |
| 181 | : base_t(true, first, last, comp, a) |
| 182 | {} |
| 183 | |
| 184 | //! <b>Effects</b>: Constructs an empty set and |
| 185 | //! inserts elements from the ordered unique range [first ,last). This function |
| 186 | //! is more efficient than the normal range creation for ordered ranges. |
| 187 | //! |
| 188 | //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be |
| 189 | //! unique values. |
| 190 | //! |
| 191 | //! <b>Complexity</b>: Linear in N. |
| 192 | //! |
| 193 | //! <b>Note</b>: Non-standard extension. |
| 194 | template <class InputIterator> |
| 195 | BOOST_CONTAINER_FORCEINLINE set( ordered_unique_range_t, InputIterator first, InputIterator last) |
| 196 | : base_t(ordered_range, first, last) |
| 197 | {} |
| 198 | |
| 199 | //! <b>Effects</b>: Constructs an empty set using the specified comparison object and |
| 200 | //! inserts elements from the ordered unique range [first ,last). This function |
| 201 | //! is more efficient than the normal range creation for ordered ranges. |
| 202 | //! |
| 203 | //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be |
| 204 | //! unique values. |
| 205 | //! |
| 206 | //! <b>Complexity</b>: Linear in N. |
| 207 | //! |
| 208 | //! <b>Note</b>: Non-standard extension. |
| 209 | template <class InputIterator> |
| 210 | BOOST_CONTAINER_FORCEINLINE set( ordered_unique_range_t, InputIterator first, InputIterator last, const Compare& comp ) |
| 211 | : base_t(ordered_range, first, last, comp) |
| 212 | {} |
| 213 | |
| 214 | //! <b>Effects</b>: Constructs an empty set using the specified comparison object and |
| 215 | //! allocator, and inserts elements from the ordered unique range [first ,last). This function |
| 216 | //! is more efficient than the normal range creation for ordered ranges. |
| 217 | //! |
| 218 | //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be |
| 219 | //! unique values. |
| 220 | //! |
| 221 | //! <b>Complexity</b>: Linear in N. |
| 222 | //! |
| 223 | //! <b>Note</b>: Non-standard extension. |
| 224 | template <class InputIterator> |
| 225 | BOOST_CONTAINER_FORCEINLINE set( ordered_unique_range_t, InputIterator first, InputIterator last |
| 226 | , const Compare& comp, const allocator_type& a) |
| 227 | : base_t(ordered_range, first, last, comp, a) |
| 228 | {} |
| 229 | |
| 230 | #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) |
| 231 | //! <b>Effects</b>: Constructs an empty set and |
| 232 | //! inserts elements from the range [il.begin(), il.end()). |
| 233 | //! |
| 234 | //! <b>Complexity</b>: Linear in N if the range [il.begin(), il.end()) is already sorted using |
| 235 | //! the predicate and otherwise N logN, where N is il.begin() - il.end(). |
| 236 | BOOST_CONTAINER_FORCEINLINE set(std::initializer_list<value_type> il) |
| 237 | : base_t(true, il.begin(), il.end()) |
| 238 | {} |
| 239 | |
| 240 | //! <b>Effects</b>: Constructs an empty set using the specified |
| 241 | //! allocator, and inserts elements from the range [il.begin(), il.end()). |
| 242 | //! |
| 243 | //! <b>Complexity</b>: Linear in N if the range [il.begin(), il.end()) is already sorted using |
| 244 | //! the predicate and otherwise N logN, where N is il.begin() - il.end(). |
| 245 | BOOST_CONTAINER_FORCEINLINE set(std::initializer_list<value_type> il, const allocator_type& a) |
| 246 | : base_t(true, il.begin(), il.end(), Compare(), a) |
| 247 | {} |
| 248 | |
| 249 | //! <b>Effects</b>: Constructs an empty set using the specified comparison object and |
| 250 | //! inserts elements from the range [il.begin(), il.end()). |
| 251 | //! |
| 252 | //! <b>Complexity</b>: Linear in N if the range [il.begin(), il.end()) is already sorted using |
| 253 | //! the predicate and otherwise N logN, where N is il.begin() - il.end(). |
| 254 | BOOST_CONTAINER_FORCEINLINE set(std::initializer_list<value_type> il, const Compare& comp ) |
| 255 | : base_t(true, il.begin(), il.end(), comp) |
| 256 | {} |
| 257 | |
| 258 | //! <b>Effects</b>: Constructs an empty set using the specified comparison object and |
| 259 | //! allocator, and inserts elements from the range [il.begin(), il.end()). |
| 260 | //! |
| 261 | //! <b>Complexity</b>: Linear in N if the range [il.begin(), il.end()) is already sorted using |
| 262 | //! the predicate and otherwise N logN, where N is il.begin() - il.end(). |
| 263 | BOOST_CONTAINER_FORCEINLINE set(std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a) |
| 264 | : base_t(true, il.begin(), il.end(), comp, a) |
| 265 | {} |
| 266 | |
| 267 | //! <b>Effects</b>: Constructs an empty set and |
| 268 | //! inserts elements from the ordered unique range [il.begin(), il.end()). This function |
| 269 | //! is more efficient than the normal range creation for ordered ranges. |
| 270 | //! |
| 271 | //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be |
| 272 | //! unique values. |
| 273 | //! |
| 274 | //! <b>Complexity</b>: Linear in N. |
| 275 | //! |
| 276 | //! <b>Note</b>: Non-standard extension. |
| 277 | BOOST_CONTAINER_FORCEINLINE set( ordered_unique_range_t, std::initializer_list<value_type> il) |
| 278 | : base_t(ordered_range, il.begin(), il.end()) |
| 279 | {} |
| 280 | |
| 281 | //! <b>Effects</b>: Constructs an empty set using the specified comparison object and |
| 282 | //! inserts elements from the ordered unique range [il.begin(), il.end()). This function |
| 283 | //! is more efficient than the normal range creation for ordered ranges. |
| 284 | //! |
| 285 | //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be |
| 286 | //! unique values. |
| 287 | //! |
| 288 | //! <b>Complexity</b>: Linear in N. |
| 289 | //! |
| 290 | //! <b>Note</b>: Non-standard extension. |
| 291 | BOOST_CONTAINER_FORCEINLINE set( ordered_unique_range_t, std::initializer_list<value_type> il, const Compare& comp) |
| 292 | : base_t(ordered_range, il.begin(), il.end(), comp) |
| 293 | {} |
| 294 | |
| 295 | //! <b>Effects</b>: Constructs an empty set using the specified comparison object and |
| 296 | //! allocator, and inserts elements from the ordered unique range [il.begin(), il.end()). This function |
| 297 | //! is more efficient than the normal range creation for ordered ranges. |
| 298 | //! |
| 299 | //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be |
| 300 | //! unique values. |
| 301 | //! |
| 302 | //! <b>Complexity</b>: Linear in N. |
| 303 | //! |
| 304 | //! <b>Note</b>: Non-standard extension. |
| 305 | BOOST_CONTAINER_FORCEINLINE set( ordered_unique_range_t, std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a) |
| 306 | : base_t(ordered_range, il.begin(), il.end(), comp, a) |
| 307 | {} |
| 308 | #endif |
| 309 | |
| 310 | //! <b>Effects</b>: Copy constructs a set. |
| 311 | //! |
| 312 | //! <b>Complexity</b>: Linear in x.size(). |
| 313 | BOOST_CONTAINER_FORCEINLINE set(const set& x) |
| 314 | : base_t(static_cast<const base_t&>(x)) |
| 315 | {} |
| 316 | |
| 317 | //! <b>Effects</b>: Move constructs a set. Constructs *this using x's resources. |
| 318 | //! |
| 319 | //! <b>Complexity</b>: Constant. |
| 320 | //! |
| 321 | //! <b>Postcondition</b>: x is emptied. |
| 322 | BOOST_CONTAINER_FORCEINLINE set(BOOST_RV_REF(set) x) |
| 323 | BOOST_NOEXCEPT_IF(boost::container::dtl::is_nothrow_move_constructible<Compare>::value) |
| 324 | : base_t(BOOST_MOVE_BASE(base_t, x)) |
| 325 | {} |
| 326 | |
| 327 | //! <b>Effects</b>: Copy constructs a set using the specified allocator. |
| 328 | //! |
| 329 | //! <b>Complexity</b>: Linear in x.size(). |
| 330 | BOOST_CONTAINER_FORCEINLINE set(const set& x, const allocator_type &a) |
| 331 | : base_t(static_cast<const base_t&>(x), a) |
| 332 | {} |
| 333 | |
| 334 | //! <b>Effects</b>: Move constructs a set using the specified allocator. |
| 335 | //! Constructs *this using x's resources. |
| 336 | //! |
| 337 | //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise. |
| 338 | BOOST_CONTAINER_FORCEINLINE set(BOOST_RV_REF(set) x, const allocator_type &a) |
| 339 | : base_t(BOOST_MOVE_BASE(base_t, x), a) |
| 340 | {} |
| 341 | |
| 342 | //! <b>Effects</b>: Makes *this a copy of x. |
| 343 | //! |
| 344 | //! <b>Complexity</b>: Linear in x.size(). |
| 345 | BOOST_CONTAINER_FORCEINLINE set& operator=(BOOST_COPY_ASSIGN_REF(set) x) |
| 346 | { return static_cast<set&>(this->base_t::operator=(static_cast<const base_t&>(x))); } |
| 347 | |
| 348 | //! <b>Effects</b>: this->swap(x.get()). |
| 349 | //! |
| 350 | //! <b>Throws</b>: If allocator_traits_type::propagate_on_container_move_assignment |
| 351 | //! is false and (allocation throws or value_type's move constructor throws) |
| 352 | //! |
| 353 | //! <b>Complexity</b>: Constant if allocator_traits_type:: |
| 354 | //! propagate_on_container_move_assignment is true or |
| 355 | //! this->get>allocator() == x.get_allocator(). Linear otherwise. |
| 356 | BOOST_CONTAINER_FORCEINLINE set& operator=(BOOST_RV_REF(set) x) |
| 357 | BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value || |
| 358 | allocator_traits_type::is_always_equal::value) && |
| 359 | boost::container::dtl::is_nothrow_move_assignable<Compare>::value) |
| 360 | { return static_cast<set&>(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); } |
| 361 | |
| 362 | #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) |
| 363 | //! <b>Effects</b>: Copy all elements from il to *this. |
| 364 | //! |
| 365 | //! <b>Complexity</b>: Linear in il.size(). |
| 366 | set& operator=(std::initializer_list<value_type> il) |
| 367 | { |
| 368 | this->clear(); |
| 369 | insert(il.begin(), il.end()); |
| 370 | return *this; |
| 371 | } |
| 372 | #endif |
| 373 | |
| 374 | #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 375 | |
| 376 | //! <b>Effects</b>: Returns a copy of the allocator that |
| 377 | //! was passed to the object's constructor. |
| 378 | //! |
| 379 | //! <b>Complexity</b>: Constant. |
| 380 | allocator_type get_allocator() const; |
| 381 | |
| 382 | //! <b>Effects</b>: Returns a reference to the internal allocator. |
| 383 | //! |
| 384 | //! <b>Throws</b>: Nothing |
| 385 | //! |
| 386 | //! <b>Complexity</b>: Constant. |
| 387 | //! |
| 388 | //! <b>Note</b>: Non-standard extension. |
| 389 | stored_allocator_type &get_stored_allocator(); |
| 390 | |
| 391 | //! <b>Effects</b>: Returns a reference to the internal allocator. |
| 392 | //! |
| 393 | //! <b>Throws</b>: Nothing |
| 394 | //! |
| 395 | //! <b>Complexity</b>: Constant. |
| 396 | //! |
| 397 | //! <b>Note</b>: Non-standard extension. |
| 398 | const stored_allocator_type &get_stored_allocator() const; |
| 399 | |
| 400 | //! <b>Effects</b>: Returns an iterator to the first element contained in the container. |
| 401 | //! |
| 402 | //! <b>Throws</b>: Nothing. |
| 403 | //! |
| 404 | //! <b>Complexity</b>: Constant |
| 405 | iterator begin(); |
| 406 | |
| 407 | //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container. |
| 408 | //! |
| 409 | //! <b>Throws</b>: Nothing. |
| 410 | //! |
| 411 | //! <b>Complexity</b>: Constant. |
| 412 | const_iterator begin() const; |
| 413 | |
| 414 | //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container. |
| 415 | //! |
| 416 | //! <b>Throws</b>: Nothing. |
| 417 | //! |
| 418 | //! <b>Complexity</b>: Constant. |
| 419 | const_iterator cbegin() const; |
| 420 | |
| 421 | //! <b>Effects</b>: Returns an iterator to the end of the container. |
| 422 | //! |
| 423 | //! <b>Throws</b>: Nothing. |
| 424 | //! |
| 425 | //! <b>Complexity</b>: Constant. |
| 426 | iterator end(); |
| 427 | |
| 428 | //! <b>Effects</b>: Returns a const_iterator to the end of the container. |
| 429 | //! |
| 430 | //! <b>Throws</b>: Nothing. |
| 431 | //! |
| 432 | //! <b>Complexity</b>: Constant. |
| 433 | const_iterator end() const; |
| 434 | |
| 435 | //! <b>Effects</b>: Returns a const_iterator to the end of the container. |
| 436 | //! |
| 437 | //! <b>Throws</b>: Nothing. |
| 438 | //! |
| 439 | //! <b>Complexity</b>: Constant. |
| 440 | const_iterator cend() const; |
| 441 | |
| 442 | //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning |
| 443 | //! of the reversed container. |
| 444 | //! |
| 445 | //! <b>Throws</b>: Nothing. |
| 446 | //! |
| 447 | //! <b>Complexity</b>: Constant. |
| 448 | reverse_iterator rbegin(); |
| 449 | |
| 450 | //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning |
| 451 | //! of the reversed container. |
| 452 | //! |
| 453 | //! <b>Throws</b>: Nothing. |
| 454 | //! |
| 455 | //! <b>Complexity</b>: Constant. |
| 456 | const_reverse_iterator rbegin() const; |
| 457 | |
| 458 | //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning |
| 459 | //! of the reversed container. |
| 460 | //! |
| 461 | //! <b>Throws</b>: Nothing. |
| 462 | //! |
| 463 | //! <b>Complexity</b>: Constant. |
| 464 | const_reverse_iterator crbegin() const; |
| 465 | |
| 466 | //! <b>Effects</b>: Returns a reverse_iterator pointing to the end |
| 467 | //! of the reversed container. |
| 468 | //! |
| 469 | //! <b>Throws</b>: Nothing. |
| 470 | //! |
| 471 | //! <b>Complexity</b>: Constant. |
| 472 | reverse_iterator rend(); |
| 473 | |
| 474 | //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end |
| 475 | //! of the reversed container. |
| 476 | //! |
| 477 | //! <b>Throws</b>: Nothing. |
| 478 | //! |
| 479 | //! <b>Complexity</b>: Constant. |
| 480 | const_reverse_iterator rend() const; |
| 481 | |
| 482 | //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end |
| 483 | //! of the reversed container. |
| 484 | //! |
| 485 | //! <b>Throws</b>: Nothing. |
| 486 | //! |
| 487 | //! <b>Complexity</b>: Constant. |
| 488 | const_reverse_iterator crend() const; |
| 489 | |
| 490 | //! <b>Effects</b>: Returns true if the container contains no elements. |
| 491 | //! |
| 492 | //! <b>Throws</b>: Nothing. |
| 493 | //! |
| 494 | //! <b>Complexity</b>: Constant. |
| 495 | bool empty() const; |
| 496 | |
| 497 | //! <b>Effects</b>: Returns the number of the elements contained in the container. |
| 498 | //! |
| 499 | //! <b>Throws</b>: Nothing. |
| 500 | //! |
| 501 | //! <b>Complexity</b>: Constant. |
| 502 | size_type size() const; |
| 503 | |
| 504 | //! <b>Effects</b>: Returns the largest possible size of the container. |
| 505 | //! |
| 506 | //! <b>Throws</b>: Nothing. |
| 507 | //! |
| 508 | //! <b>Complexity</b>: Constant. |
| 509 | size_type max_size() const; |
| 510 | #endif // #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 511 | |
| 512 | #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 513 | |
| 514 | //! <b>Effects</b>: Inserts an object x of type Key constructed with |
| 515 | //! std::forward<Args>(args)... if and only if there is |
| 516 | //! no element in the container with equivalent value. |
| 517 | //! and returns the iterator pointing to the |
| 518 | //! newly inserted element. |
| 519 | //! |
| 520 | //! <b>Returns</b>: The bool component of the returned pair is true if and only |
| 521 | //! if the insertion takes place, and the iterator component of the pair |
| 522 | //! points to the element with key equivalent to the key of x. |
| 523 | //! |
| 524 | //! <b>Throws</b>: If memory allocation throws or |
| 525 | //! Key's in-place constructor throws. |
| 526 | //! |
| 527 | //! <b>Complexity</b>: Logarithmic. |
| 528 | template <class... Args> |
| 529 | BOOST_CONTAINER_FORCEINLINE std::pair<iterator,bool> emplace(BOOST_FWD_REF(Args)... args) |
| 530 | { return this->base_t::emplace_unique(boost::forward<Args>(args)...); } |
| 531 | |
| 532 | //! <b>Effects</b>: Inserts an object of type Key constructed with |
| 533 | //! std::forward<Args>(args)... if and only if there is |
| 534 | //! no element in the container with equivalent value. |
| 535 | //! p is a hint pointing to where the insert |
| 536 | //! should start to search. |
| 537 | //! |
| 538 | //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x. |
| 539 | //! |
| 540 | //! <b>Complexity</b>: Logarithmic. |
| 541 | template <class... Args> |
| 542 | BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args) |
| 543 | { return this->base_t::emplace_hint_unique(p, boost::forward<Args>(args)...); } |
| 544 | |
| 545 | #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) |
| 546 | |
| 547 | #define BOOST_CONTAINER_SET_EMPLACE_CODE(N) \ |
| 548 | BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ |
| 549 | BOOST_CONTAINER_FORCEINLINE std::pair<iterator,bool> emplace(BOOST_MOVE_UREF##N)\ |
| 550 | { return this->base_t::emplace_unique(BOOST_MOVE_FWD##N); }\ |
| 551 | \ |
| 552 | BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ |
| 553 | BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ |
| 554 | { return this->base_t::emplace_hint_unique(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\ |
| 555 | // |
| 556 | BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_SET_EMPLACE_CODE) |
| 557 | #undef BOOST_CONTAINER_SET_EMPLACE_CODE |
| 558 | |
| 559 | #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) |
| 560 | |
| 561 | #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 562 | //! <b>Effects</b>: Inserts x if and only if there is no element in the container |
| 563 | //! with key equivalent to the key of x. |
| 564 | //! |
| 565 | //! <b>Returns</b>: The bool component of the returned pair is true if and only |
| 566 | //! if the insertion takes place, and the iterator component of the pair |
| 567 | //! points to the element with key equivalent to the key of x. |
| 568 | //! |
| 569 | //! <b>Complexity</b>: Logarithmic. |
| 570 | std::pair<iterator, bool> insert(const value_type &x); |
| 571 | |
| 572 | //! <b>Effects</b>: Move constructs a new value from x if and only if there is |
| 573 | //! no element in the container with key equivalent to the key of x. |
| 574 | //! |
| 575 | //! <b>Returns</b>: The bool component of the returned pair is true if and only |
| 576 | //! if the insertion takes place, and the iterator component of the pair |
| 577 | //! points to the element with key equivalent to the key of x. |
| 578 | //! |
| 579 | //! <b>Complexity</b>: Logarithmic. |
| 580 | std::pair<iterator, bool> insert(value_type &&x); |
| 581 | #else |
| 582 | private: |
| 583 | typedef std::pair<iterator, bool> insert_return_pair; |
| 584 | public: |
| 585 | BOOST_MOVE_CONVERSION_AWARE_CATCH(insert, value_type, insert_return_pair, this->priv_insert) |
| 586 | #endif |
| 587 | |
| 588 | #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 589 | //! <b>Effects</b>: Inserts a copy of x in the container if and only if there is |
| 590 | //! no element in the container with key equivalent to the key of x. |
| 591 | //! p is a hint pointing to where the insert should start to search. |
| 592 | //! |
| 593 | //! <b>Returns</b>: An iterator pointing to the element with key equivalent |
| 594 | //! to the key of x. |
| 595 | //! |
| 596 | //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t |
| 597 | //! is inserted right before p. |
| 598 | iterator insert(const_iterator p, const value_type &x); |
| 599 | |
| 600 | //! <b>Effects</b>: Inserts an element move constructed from x in the container. |
| 601 | //! p is a hint pointing to where the insert should start to search. |
| 602 | //! |
| 603 | //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x. |
| 604 | //! |
| 605 | //! <b>Complexity</b>: Logarithmic. |
| 606 | iterator insert(const_iterator p, value_type &&x); |
| 607 | #else |
| 608 | BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, value_type, iterator, this->priv_insert, const_iterator, const_iterator) |
| 609 | #endif |
| 610 | |
| 611 | //! <b>Requires</b>: first, last are not iterators into *this. |
| 612 | //! |
| 613 | //! <b>Effects</b>: inserts each element from the range [first,last) if and only |
| 614 | //! if there is no element with key equivalent to the key of that element. |
| 615 | //! |
| 616 | //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last) |
| 617 | template <class InputIterator> |
| 618 | BOOST_CONTAINER_FORCEINLINE void insert(InputIterator first, InputIterator last) |
| 619 | { this->base_t::insert_unique(first, last); } |
| 620 | |
| 621 | #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) |
| 622 | //! <b>Effects</b>: inserts each element from the range [il.begin(),il.end()) if and only |
| 623 | //! if there is no element with key equivalent to the key of that element. |
| 624 | //! |
| 625 | //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from il.begin() to il.end()) |
| 626 | BOOST_CONTAINER_FORCEINLINE void insert(std::initializer_list<value_type> il) |
| 627 | { this->base_t::insert_unique(il.begin(), il.end()); } |
| 628 | #endif |
| 629 | |
| 630 | //! @copydoc ::boost::container::map::insert(node_type&&) |
| 631 | BOOST_CONTAINER_FORCEINLINE insert_return_type insert(BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh) |
| 632 | { return this->base_t::insert_unique_node(boost::move(nh)); } |
| 633 | |
| 634 | //! @copydoc ::boost::container::map::insert(const_iterator, node_type&&) |
| 635 | BOOST_CONTAINER_FORCEINLINE insert_return_type insert(const_iterator hint, BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh) |
| 636 | { return this->base_t::insert_unique_node(hint, boost::move(nh)); } |
| 637 | |
| 638 | //! @copydoc ::boost::container::map::merge(map<Key, T, C2, Allocator, Options>&) |
| 639 | template<class C2> |
| 640 | BOOST_CONTAINER_FORCEINLINE void merge(set<Key, C2, Allocator, Options>& source) |
| 641 | { |
| 642 | typedef dtl::tree |
| 643 | <Key, dtl::identity<Key>, C2, Allocator, Options> base2_t; |
| 644 | this->base_t::merge_unique(static_cast<base2_t&>(source)); |
| 645 | } |
| 646 | |
| 647 | //! @copydoc ::boost::container::set::merge(set<Key, C2, Allocator, Options>&) |
| 648 | template<class C2> |
| 649 | BOOST_CONTAINER_FORCEINLINE void merge(BOOST_RV_REF_BEG set<Key, C2, Allocator, Options> BOOST_RV_REF_END source) |
| 650 | { return this->merge(static_cast<set<Key, C2, Allocator, Options>&>(source)); } |
| 651 | |
| 652 | //! @copydoc ::boost::container::map::merge(multimap<Key, T, C2, Allocator, Options>&) |
| 653 | template<class C2> |
| 654 | BOOST_CONTAINER_FORCEINLINE void merge(multiset<Key, C2, Allocator, Options>& source) |
| 655 | { |
| 656 | typedef dtl::tree |
| 657 | <Key, dtl::identity<Key>, C2, Allocator, Options> base2_t; |
| 658 | this->base_t::merge_unique(static_cast<base2_t&>(source)); |
| 659 | } |
| 660 | |
| 661 | //! @copydoc ::boost::container::set::merge(multiset<Key, C2, Allocator, Options>&) |
| 662 | template<class C2> |
| 663 | BOOST_CONTAINER_FORCEINLINE void merge(BOOST_RV_REF_BEG multiset<Key, C2, Allocator, Options> BOOST_RV_REF_END source) |
| 664 | { return this->merge(static_cast<multiset<Key, C2, Allocator, Options>&>(source)); } |
| 665 | |
| 666 | #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 667 | |
| 668 | //! <b>Effects</b>: Erases the element pointed to by p. |
| 669 | //! |
| 670 | //! <b>Returns</b>: Returns an iterator pointing to the element immediately |
| 671 | //! following q prior to the element being erased. If no such element exists, |
| 672 | //! returns end(). |
| 673 | //! |
| 674 | //! <b>Complexity</b>: Amortized constant time |
| 675 | iterator erase(const_iterator p); |
| 676 | |
| 677 | //! <b>Effects</b>: Erases all elements in the container with key equivalent to x. |
| 678 | //! |
| 679 | //! <b>Returns</b>: Returns the number of erased elements. |
| 680 | //! |
| 681 | //! <b>Complexity</b>: log(size()) + count(k) |
| 682 | size_type erase(const key_type& x); |
| 683 | |
| 684 | //! <b>Effects</b>: Erases all the elements in the range [first, last). |
| 685 | //! |
| 686 | //! <b>Returns</b>: Returns last. |
| 687 | //! |
| 688 | //! <b>Complexity</b>: log(size())+N where N is the distance from first to last. |
| 689 | iterator erase(const_iterator first, const_iterator last); |
| 690 | |
| 691 | //! @copydoc ::boost::container::map::extract(const_iterator) |
| 692 | node_type extract(const_iterator p); |
| 693 | |
| 694 | //! @copydoc ::boost::container::map::extract(const key_type&) |
| 695 | node_type extract(const key_type& x); |
| 696 | |
| 697 | //! <b>Effects</b>: Swaps the contents of *this and x. |
| 698 | //! |
| 699 | //! <b>Throws</b>: Nothing. |
| 700 | //! |
| 701 | //! <b>Complexity</b>: Constant. |
| 702 | void swap(set& x) |
| 703 | BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value |
| 704 | && boost::container::dtl::is_nothrow_swappable<Compare>::value ); |
| 705 | |
| 706 | //! <b>Effects</b>: erase(a.begin(),a.end()). |
| 707 | //! |
| 708 | //! <b>Postcondition</b>: size() == 0. |
| 709 | //! |
| 710 | //! <b>Complexity</b>: linear in size(). |
| 711 | void clear(); |
| 712 | |
| 713 | //! <b>Effects</b>: Returns the comparison object out |
| 714 | //! of which a was constructed. |
| 715 | //! |
| 716 | //! <b>Complexity</b>: Constant. |
| 717 | key_compare key_comp() const; |
| 718 | |
| 719 | //! <b>Effects</b>: Returns an object of value_compare constructed out |
| 720 | //! of the comparison object. |
| 721 | //! |
| 722 | //! <b>Complexity</b>: Constant. |
| 723 | value_compare value_comp() const; |
| 724 | |
| 725 | //! <b>Returns</b>: An iterator pointing to an element with the key |
| 726 | //! equivalent to x, or end() if such an element is not found. |
| 727 | //! |
| 728 | //! <b>Complexity</b>: Logarithmic. |
| 729 | iterator find(const key_type& x); |
| 730 | |
| 731 | //! <b>Returns</b>: A const_iterator pointing to an element with the key |
| 732 | //! equivalent to x, or end() if such an element is not found. |
| 733 | //! |
| 734 | //! <b>Complexity</b>: Logarithmic. |
| 735 | const_iterator find(const key_type& x) const; |
| 736 | |
| 737 | //! <b>Requires</b>: This overload is available only if |
| 738 | //! key_compare::is_transparent exists. |
| 739 | //! |
| 740 | //! <b>Returns</b>: An iterator pointing to an element with the key |
| 741 | //! equivalent to x, or end() if such an element is not found. |
| 742 | //! |
| 743 | //! <b>Complexity</b>: Logarithmic. |
| 744 | template<typename K> |
| 745 | iterator find(const K& x); |
| 746 | |
| 747 | //! <b>Requires</b>: This overload is available only if |
| 748 | //! key_compare::is_transparent exists. |
| 749 | //! |
| 750 | //! <b>Returns</b>: A const_iterator pointing to an element with the key |
| 751 | //! equivalent to x, or end() if such an element is not found. |
| 752 | //! |
| 753 | //! <b>Complexity</b>: Logarithmic. |
| 754 | template<typename K> |
| 755 | const_iterator find(const K& x) const; |
| 756 | |
| 757 | #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 758 | |
| 759 | //! <b>Returns</b>: The number of elements with key equivalent to x. |
| 760 | //! |
| 761 | //! <b>Complexity</b>: log(size())+count(k) |
| 762 | BOOST_CONTAINER_FORCEINLINE size_type count(const key_type& x) const |
| 763 | { return static_cast<size_type>(this->base_t::find(x) != this->base_t::cend()); } |
| 764 | |
| 765 | //! <b>Requires</b>: This overload is available only if |
| 766 | //! key_compare::is_transparent exists. |
| 767 | //! |
| 768 | //! <b>Returns</b>: The number of elements with key equivalent to x. |
| 769 | //! |
| 770 | //! <b>Complexity</b>: log(size())+count(k) |
| 771 | template<typename K> |
| 772 | BOOST_CONTAINER_FORCEINLINE size_type count(const K& x) const |
| 773 | { return static_cast<size_type>(this->find(x) != this->cend()); } |
| 774 | |
| 775 | //! <b>Returns</b>: The number of elements with key equivalent to x. |
| 776 | //! |
| 777 | //! <b>Complexity</b>: log(size())+count(k) |
| 778 | BOOST_CONTAINER_FORCEINLINE size_type count(const key_type& x) |
| 779 | { return static_cast<size_type>(this->base_t::find(x) != this->base_t::end()); } |
| 780 | |
| 781 | #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 782 | |
| 783 | //! <b>Returns</b>: An iterator pointing to the first element with key not less |
| 784 | //! than k, or a.end() if such an element is not found. |
| 785 | //! |
| 786 | //! <b>Complexity</b>: Logarithmic |
| 787 | iterator lower_bound(const key_type& x); |
| 788 | |
| 789 | //! <b>Returns</b>: A const iterator pointing to the first element with key not |
| 790 | //! less than k, or a.end() if such an element is not found. |
| 791 | //! |
| 792 | //! <b>Complexity</b>: Logarithmic |
| 793 | const_iterator lower_bound(const key_type& x) const; |
| 794 | |
| 795 | //! <b>Requires</b>: This overload is available only if |
| 796 | //! key_compare::is_transparent exists. |
| 797 | //! |
| 798 | //! <b>Returns</b>: An iterator pointing to the first element with key not less |
| 799 | //! than k, or a.end() if such an element is not found. |
| 800 | //! |
| 801 | //! <b>Complexity</b>: Logarithmic |
| 802 | template<typename K> |
| 803 | iterator lower_bound(const K& x); |
| 804 | |
| 805 | //! <b>Requires</b>: This overload is available only if |
| 806 | //! key_compare::is_transparent exists. |
| 807 | //! |
| 808 | //! <b>Returns</b>: A const iterator pointing to the first element with key not |
| 809 | //! less than k, or a.end() if such an element is not found. |
| 810 | //! |
| 811 | //! <b>Complexity</b>: Logarithmic |
| 812 | template<typename K> |
| 813 | const_iterator lower_bound(const K& x) const; |
| 814 | |
| 815 | //! <b>Returns</b>: An iterator pointing to the first element with key not less |
| 816 | //! than x, or end() if such an element is not found. |
| 817 | //! |
| 818 | //! <b>Complexity</b>: Logarithmic |
| 819 | iterator upper_bound(const key_type& x); |
| 820 | |
| 821 | //! <b>Returns</b>: A const iterator pointing to the first element with key not |
| 822 | //! less than x, or end() if such an element is not found. |
| 823 | //! |
| 824 | //! <b>Complexity</b>: Logarithmic |
| 825 | const_iterator upper_bound(const key_type& x) const; |
| 826 | |
| 827 | //! <b>Requires</b>: This overload is available only if |
| 828 | //! key_compare::is_transparent exists. |
| 829 | //! |
| 830 | //! <b>Returns</b>: An iterator pointing to the first element with key not less |
| 831 | //! than x, or end() if such an element is not found. |
| 832 | //! |
| 833 | //! <b>Complexity</b>: Logarithmic |
| 834 | template<typename K> |
| 835 | iterator upper_bound(const K& x); |
| 836 | |
| 837 | //! <b>Requires</b>: This overload is available only if |
| 838 | //! key_compare::is_transparent exists. |
| 839 | //! |
| 840 | //! <b>Returns</b>: A const iterator pointing to the first element with key not |
| 841 | //! less than x, or end() if such an element is not found. |
| 842 | //! |
| 843 | //! <b>Complexity</b>: Logarithmic |
| 844 | template<typename K> |
| 845 | const_iterator upper_bound(const K& x) const; |
| 846 | |
| 847 | #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 848 | |
| 849 | //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). |
| 850 | //! |
| 851 | //! <b>Complexity</b>: Logarithmic |
| 852 | BOOST_CONTAINER_FORCEINLINE std::pair<iterator,iterator> equal_range(const key_type& x) |
| 853 | { return this->base_t::lower_bound_range(x); } |
| 854 | |
| 855 | //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). |
| 856 | //! |
| 857 | //! <b>Complexity</b>: Logarithmic |
| 858 | BOOST_CONTAINER_FORCEINLINE std::pair<const_iterator, const_iterator> equal_range(const key_type& x) const |
| 859 | { return this->base_t::lower_bound_range(x); } |
| 860 | |
| 861 | //! <b>Requires</b>: This overload is available only if |
| 862 | //! key_compare::is_transparent exists. |
| 863 | //! |
| 864 | //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). |
| 865 | //! |
| 866 | //! <b>Complexity</b>: Logarithmic |
| 867 | template<typename K> |
| 868 | std::pair<iterator,iterator> equal_range(const K& x) |
| 869 | { return this->base_t::lower_bound_range(x); } |
| 870 | |
| 871 | //! <b>Requires</b>: This overload is available only if |
| 872 | //! key_compare::is_transparent exists. |
| 873 | //! |
| 874 | //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). |
| 875 | //! |
| 876 | //! <b>Complexity</b>: Logarithmic |
| 877 | template<typename K> |
| 878 | std::pair<const_iterator,const_iterator> equal_range(const K& x) const |
| 879 | { return this->base_t::lower_bound_range(x); } |
| 880 | |
| 881 | #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 882 | |
| 883 | //! <b>Effects</b>: Rebalances the tree. It's a no-op for Red-Black and AVL trees. |
| 884 | //! |
| 885 | //! <b>Complexity</b>: Linear |
| 886 | void rebalance(); |
| 887 | |
| 888 | //! <b>Effects</b>: Returns true if x and y are equal |
| 889 | //! |
| 890 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 891 | friend bool operator==(const set& x, const set& y); |
| 892 | |
| 893 | //! <b>Effects</b>: Returns true if x and y are unequal |
| 894 | //! |
| 895 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 896 | friend bool operator!=(const set& x, const set& y); |
| 897 | |
| 898 | //! <b>Effects</b>: Returns true if x is less than y |
| 899 | //! |
| 900 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 901 | friend bool operator<(const set& x, const set& y); |
| 902 | |
| 903 | //! <b>Effects</b>: Returns true if x is greater than y |
| 904 | //! |
| 905 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 906 | friend bool operator>(const set& x, const set& y); |
| 907 | |
| 908 | //! <b>Effects</b>: Returns true if x is equal or less than y |
| 909 | //! |
| 910 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 911 | friend bool operator<=(const set& x, const set& y); |
| 912 | |
| 913 | //! <b>Effects</b>: Returns true if x is equal or greater than y |
| 914 | //! |
| 915 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 916 | friend bool operator>=(const set& x, const set& y); |
| 917 | |
| 918 | //! <b>Effects</b>: x.swap(y) |
| 919 | //! |
| 920 | //! <b>Complexity</b>: Constant. |
| 921 | friend void swap(set& x, set& y); |
| 922 | |
| 923 | #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 924 | |
| 925 | #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 926 | private: |
| 927 | template <class KeyType> |
| 928 | BOOST_CONTAINER_FORCEINLINE std::pair<iterator, bool> priv_insert(BOOST_FWD_REF(KeyType) x) |
| 929 | { return this->base_t::insert_unique(::boost::forward<KeyType>(x)); } |
| 930 | |
| 931 | template <class KeyType> |
| 932 | BOOST_CONTAINER_FORCEINLINE iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x) |
| 933 | { return this->base_t::insert_unique(p, ::boost::forward<KeyType>(x)); } |
| 934 | #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 935 | }; |
| 936 | |
| 937 | #if __cplusplus >= 201703L |
| 938 | |
| 939 | template <typename InputIterator> |
| 940 | set(InputIterator, InputIterator) -> |
| 941 | set<typename iterator_traits<InputIterator>::value_type>; |
| 942 | |
| 943 | template <typename InputIterator, typename Allocator> |
| 944 | set(InputIterator, InputIterator, Allocator const&) -> |
| 945 | set<typename iterator_traits<InputIterator>::value_type, std::less<typename iterator_traits<InputIterator>::value_type>, Allocator>; |
| 946 | |
| 947 | template <typename InputIterator, typename Compare> |
| 948 | set(InputIterator, InputIterator, Compare const&) -> |
| 949 | set<typename iterator_traits<InputIterator>::value_type, Compare>; |
| 950 | |
| 951 | template <typename InputIterator, typename Compare, typename Allocator> |
| 952 | set(InputIterator, InputIterator, Compare const&, Allocator const&) -> |
| 953 | set<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>; |
| 954 | |
| 955 | template <typename InputIterator> |
| 956 | set(ordered_unique_range_t, InputIterator, InputIterator) -> |
| 957 | set<typename iterator_traits<InputIterator>::value_type>; |
| 958 | |
| 959 | template <typename InputIterator, typename Allocator> |
| 960 | set(ordered_unique_range_t, InputIterator, InputIterator, Allocator const&) -> |
| 961 | set<typename iterator_traits<InputIterator>::value_type, std::less<typename iterator_traits<InputIterator>::value_type>, Allocator>; |
| 962 | |
| 963 | template <typename InputIterator, typename Compare> |
| 964 | set(ordered_unique_range_t, InputIterator, InputIterator, Compare const&) -> |
| 965 | set<typename iterator_traits<InputIterator>::value_type, Compare>; |
| 966 | |
| 967 | template <typename InputIterator, typename Compare, typename Allocator> |
| 968 | set(ordered_unique_range_t, InputIterator, InputIterator, Compare const&, Allocator const&) -> |
| 969 | set<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>; |
| 970 | |
| 971 | #endif |
| 972 | |
| 973 | #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 974 | |
| 975 | } //namespace container { |
| 976 | |
| 977 | //!has_trivial_destructor_after_move<> == true_type |
| 978 | //!specialization for optimizations |
| 979 | template <class Key, class Compare, class Options, class Allocator> |
| 980 | struct has_trivial_destructor_after_move<boost::container::set<Key, Compare, Allocator, Options> > |
| 981 | { |
| 982 | typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer; |
| 983 | static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value && |
| 984 | ::boost::has_trivial_destructor_after_move<pointer>::value && |
| 985 | ::boost::has_trivial_destructor_after_move<Compare>::value; |
| 986 | }; |
| 987 | |
| 988 | namespace container { |
| 989 | |
| 990 | #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 991 | |
| 992 | #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 993 | |
| 994 | //! A multiset is a kind of associative container that supports equivalent keys |
| 995 | //! (possibly contains multiple copies of the same key value) and provides for |
| 996 | //! fast retrieval of the keys themselves. Class multiset supports bidirectional iterators. |
| 997 | //! |
| 998 | //! A multiset satisfies all of the requirements of a container and of a reversible |
| 999 | //! container, and of an associative container). multiset also provides most operations |
| 1000 | //! described for duplicate keys. |
| 1001 | //! |
| 1002 | //! \tparam Key is the type to be inserted in the set, which is also the key_type |
| 1003 | //! \tparam Compare is the comparison functor used to order keys |
| 1004 | //! \tparam Allocator is the allocator to be used to allocate memory for this container |
| 1005 | //! \tparam Options is an packed option type generated using using boost::container::tree_assoc_options. |
| 1006 | template <class Key, class Compare = std::less<Key>, class Allocator = new_allocator<Key>, class Options = tree_assoc_defaults > |
| 1007 | #else |
| 1008 | template <class Key, class Compare, class Allocator, class Options> |
| 1009 | #endif |
| 1010 | class multiset |
| 1011 | /// @cond |
| 1012 | : public dtl::tree |
| 1013 | <Key,dtl::identity<Key>, Compare, Allocator, Options> |
| 1014 | /// @endcond |
| 1015 | { |
| 1016 | #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 1017 | private: |
| 1018 | BOOST_COPYABLE_AND_MOVABLE(multiset) |
| 1019 | typedef dtl::tree |
| 1020 | <Key,dtl::identity<Key>, Compare, Allocator, Options> base_t; |
| 1021 | #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 1022 | |
| 1023 | public: |
| 1024 | |
| 1025 | ////////////////////////////////////////////// |
| 1026 | // |
| 1027 | // types |
| 1028 | // |
| 1029 | ////////////////////////////////////////////// |
| 1030 | typedef Key key_type; |
| 1031 | typedef Key value_type; |
| 1032 | typedef Compare key_compare; |
| 1033 | typedef Compare value_compare; |
| 1034 | typedef ::boost::container::allocator_traits<Allocator> allocator_traits_type; |
| 1035 | typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer; |
| 1036 | typedef typename ::boost::container::allocator_traits<Allocator>::const_pointer const_pointer; |
| 1037 | typedef typename ::boost::container::allocator_traits<Allocator>::reference reference; |
| 1038 | typedef typename ::boost::container::allocator_traits<Allocator>::const_reference const_reference; |
| 1039 | typedef typename ::boost::container::allocator_traits<Allocator>::size_type size_type; |
| 1040 | typedef typename ::boost::container::allocator_traits<Allocator>::difference_type difference_type; |
| 1041 | typedef Allocator allocator_type; |
| 1042 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type; |
| 1043 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator; |
| 1044 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator; |
| 1045 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator; |
| 1046 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator; |
| 1047 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::node_type) node_type; |
| 1048 | |
| 1049 | ////////////////////////////////////////////// |
| 1050 | // |
| 1051 | // construct/copy/destroy |
| 1052 | // |
| 1053 | ////////////////////////////////////////////// |
| 1054 | |
| 1055 | //! @copydoc ::boost::container::set::set() |
| 1056 | BOOST_CONTAINER_FORCEINLINE multiset() |
| 1057 | BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible<Allocator>::value && |
| 1058 | dtl::is_nothrow_default_constructible<Compare>::value) |
| 1059 | : base_t() |
| 1060 | {} |
| 1061 | |
| 1062 | //! @copydoc ::boost::container::set::set(const allocator_type&) |
| 1063 | BOOST_CONTAINER_FORCEINLINE explicit multiset(const allocator_type& a) |
| 1064 | : base_t(a) |
| 1065 | {} |
| 1066 | |
| 1067 | //! @copydoc ::boost::container::set::set(const Compare&) |
| 1068 | BOOST_CONTAINER_FORCEINLINE explicit multiset(const Compare& comp) |
| 1069 | : base_t(comp) |
| 1070 | {} |
| 1071 | |
| 1072 | //! @copydoc ::boost::container::set::set(const Compare&, const allocator_type&) |
| 1073 | BOOST_CONTAINER_FORCEINLINE multiset(const Compare& comp, const allocator_type& a) |
| 1074 | : base_t(comp, a) |
| 1075 | {} |
| 1076 | |
| 1077 | //! @copydoc ::boost::container::set::set(InputIterator, InputIterator) |
| 1078 | template <class InputIterator> |
| 1079 | BOOST_CONTAINER_FORCEINLINE multiset(InputIterator first, InputIterator last) |
| 1080 | : base_t(false, first, last) |
| 1081 | {} |
| 1082 | |
| 1083 | //! @copydoc ::boost::container::set::set(InputIterator, InputIterator, const allocator_type&) |
| 1084 | template <class InputIterator> |
| 1085 | BOOST_CONTAINER_FORCEINLINE multiset(InputIterator first, InputIterator last, const allocator_type& a) |
| 1086 | : base_t(false, first, last, key_compare(), a) |
| 1087 | {} |
| 1088 | |
| 1089 | //! @copydoc ::boost::container::set::set(InputIterator, InputIterator, const Compare&) |
| 1090 | template <class InputIterator> |
| 1091 | BOOST_CONTAINER_FORCEINLINE multiset(InputIterator first, InputIterator last, const Compare& comp) |
| 1092 | : base_t(false, first, last, comp) |
| 1093 | {} |
| 1094 | |
| 1095 | //! @copydoc ::boost::container::set::set(InputIterator, InputIterator, const Compare&, const allocator_type&) |
| 1096 | template <class InputIterator> |
| 1097 | BOOST_CONTAINER_FORCEINLINE multiset(InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a) |
| 1098 | : base_t(false, first, last, comp, a) |
| 1099 | {} |
| 1100 | |
| 1101 | //! <b>Effects</b>: Constructs an empty multiset and |
| 1102 | //! and inserts elements from the ordered range [first ,last ). This function |
| 1103 | //! is more efficient than the normal range creation for ordered ranges. |
| 1104 | //! |
| 1105 | //! <b>Requires</b>: [first ,last) must be ordered according to the predicate. |
| 1106 | //! |
| 1107 | //! <b>Complexity</b>: Linear in N. |
| 1108 | //! |
| 1109 | //! <b>Note</b>: Non-standard extension. |
| 1110 | template <class InputIterator> |
| 1111 | BOOST_CONTAINER_FORCEINLINE multiset( ordered_range_t, InputIterator first, InputIterator last ) |
| 1112 | : base_t(ordered_range, first, last) |
| 1113 | {} |
| 1114 | |
| 1115 | //! <b>Effects</b>: Constructs an empty multiset using the specified comparison object and |
| 1116 | //! inserts elements from the ordered range [first ,last ). This function |
| 1117 | //! is more efficient than the normal range creation for ordered ranges. |
| 1118 | //! |
| 1119 | //! <b>Requires</b>: [first ,last) must be ordered according to the predicate. |
| 1120 | //! |
| 1121 | //! <b>Complexity</b>: Linear in N. |
| 1122 | //! |
| 1123 | //! <b>Note</b>: Non-standard extension. |
| 1124 | template <class InputIterator> |
| 1125 | BOOST_CONTAINER_FORCEINLINE multiset( ordered_range_t, InputIterator first, InputIterator last, const Compare& comp) |
| 1126 | : base_t(ordered_range, first, last, comp) |
| 1127 | {} |
| 1128 | |
| 1129 | //! <b>Effects</b>: Constructs an empty multiset using the specified comparison object and |
| 1130 | //! allocator, and inserts elements from the ordered range [first ,last ). This function |
| 1131 | //! is more efficient than the normal range creation for ordered ranges. |
| 1132 | //! |
| 1133 | //! <b>Requires</b>: [first ,last) must be ordered according to the predicate. |
| 1134 | //! |
| 1135 | //! <b>Complexity</b>: Linear in N. |
| 1136 | //! |
| 1137 | //! <b>Note</b>: Non-standard extension. |
| 1138 | template <class InputIterator> |
| 1139 | BOOST_CONTAINER_FORCEINLINE multiset( ordered_range_t, InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a) |
| 1140 | : base_t(ordered_range, first, last, comp, a) |
| 1141 | {} |
| 1142 | |
| 1143 | #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) |
| 1144 | //! @copydoc ::boost::container::set::set(std::initializer_list<value_type>) |
| 1145 | BOOST_CONTAINER_FORCEINLINE multiset(std::initializer_list<value_type> il) |
| 1146 | : base_t(false, il.begin(), il.end()) |
| 1147 | {} |
| 1148 | |
| 1149 | //! @copydoc ::boost::container::set::set(std::initializer_list<value_type>, const allocator_type&) |
| 1150 | BOOST_CONTAINER_FORCEINLINE multiset(std::initializer_list<value_type> il, const allocator_type& a) |
| 1151 | : base_t(false, il.begin(), il.end(), Compare(), a) |
| 1152 | {} |
| 1153 | |
| 1154 | //! @copydoc ::boost::container::set::set(std::initializer_list<value_type>, const Compare&) |
| 1155 | BOOST_CONTAINER_FORCEINLINE multiset(std::initializer_list<value_type> il, const Compare& comp) |
| 1156 | : base_t(false, il.begin(), il.end(), comp) |
| 1157 | {} |
| 1158 | |
| 1159 | //! @copydoc ::boost::container::set::set(std::initializer_list<value_type>, const Compare&, const allocator_type&) |
| 1160 | BOOST_CONTAINER_FORCEINLINE multiset(std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a) |
| 1161 | : base_t(false, il.begin(), il.end(), comp, a) |
| 1162 | {} |
| 1163 | |
| 1164 | //! @copydoc ::boost::container::set::set(ordered_unique_range_t, std::initializer_list<value_type>) |
| 1165 | BOOST_CONTAINER_FORCEINLINE multiset(ordered_range_t, std::initializer_list<value_type> il) |
| 1166 | : base_t(ordered_range, il.begin(), il.end()) |
| 1167 | {} |
| 1168 | |
| 1169 | //! @copydoc ::boost::container::set::set(ordered_unique_range_t, std::initializer_list<value_type>, const Compare&) |
| 1170 | BOOST_CONTAINER_FORCEINLINE multiset(ordered_range_t, std::initializer_list<value_type> il, const Compare& comp) |
| 1171 | : base_t(ordered_range, il.begin(), il.end(), comp) |
| 1172 | {} |
| 1173 | |
| 1174 | //! @copydoc ::boost::container::set::set(ordered_unique_range_t, std::initializer_list<value_type>, const Compare&, const allocator_type&) |
| 1175 | BOOST_CONTAINER_FORCEINLINE multiset(ordered_range_t, std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a) |
| 1176 | : base_t(ordered_range, il.begin(), il.end(), comp, a) |
| 1177 | {} |
| 1178 | #endif |
| 1179 | |
| 1180 | //! @copydoc ::boost::container::set::set(const set &) |
| 1181 | BOOST_CONTAINER_FORCEINLINE multiset(const multiset& x) |
| 1182 | : base_t(static_cast<const base_t&>(x)) |
| 1183 | {} |
| 1184 | |
| 1185 | //! @copydoc ::boost::container::set::set(set &&) |
| 1186 | BOOST_CONTAINER_FORCEINLINE multiset(BOOST_RV_REF(multiset) x) |
| 1187 | BOOST_NOEXCEPT_IF(boost::container::dtl::is_nothrow_move_constructible<Compare>::value) |
| 1188 | : base_t(BOOST_MOVE_BASE(base_t, x)) |
| 1189 | {} |
| 1190 | |
| 1191 | //! @copydoc ::boost::container::set::set(const set &, const allocator_type &) |
| 1192 | BOOST_CONTAINER_FORCEINLINE multiset(const multiset& x, const allocator_type &a) |
| 1193 | : base_t(static_cast<const base_t&>(x), a) |
| 1194 | {} |
| 1195 | |
| 1196 | //! @copydoc ::boost::container::set::set(set &&, const allocator_type &) |
| 1197 | BOOST_CONTAINER_FORCEINLINE multiset(BOOST_RV_REF(multiset) x, const allocator_type &a) |
| 1198 | : base_t(BOOST_MOVE_BASE(base_t, x), a) |
| 1199 | {} |
| 1200 | |
| 1201 | //! @copydoc ::boost::container::set::operator=(const set &) |
| 1202 | BOOST_CONTAINER_FORCEINLINE multiset& operator=(BOOST_COPY_ASSIGN_REF(multiset) x) |
| 1203 | { return static_cast<multiset&>(this->base_t::operator=(static_cast<const base_t&>(x))); } |
| 1204 | |
| 1205 | //! @copydoc ::boost::container::set::operator=(set &&) |
| 1206 | BOOST_CONTAINER_FORCEINLINE multiset& operator=(BOOST_RV_REF(multiset) x) |
| 1207 | BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value || |
| 1208 | allocator_traits_type::is_always_equal::value) && |
| 1209 | boost::container::dtl::is_nothrow_move_assignable<Compare>::value) |
| 1210 | { return static_cast<multiset&>(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); } |
| 1211 | |
| 1212 | #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) |
| 1213 | //! @copydoc ::boost::container::set::operator=(std::initializer_list<value_type>) |
| 1214 | multiset& operator=(std::initializer_list<value_type> il) |
| 1215 | { |
| 1216 | this->clear(); |
| 1217 | insert(il.begin(), il.end()); |
| 1218 | return *this; |
| 1219 | } |
| 1220 | #endif |
| 1221 | #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 1222 | |
| 1223 | //! @copydoc ::boost::container::set::get_allocator() |
| 1224 | allocator_type get_allocator() const; |
| 1225 | |
| 1226 | //! @copydoc ::boost::container::set::get_stored_allocator() |
| 1227 | stored_allocator_type &get_stored_allocator(); |
| 1228 | |
| 1229 | //! @copydoc ::boost::container::set::get_stored_allocator() const |
| 1230 | const stored_allocator_type &get_stored_allocator() const; |
| 1231 | |
| 1232 | //! @copydoc ::boost::container::set::begin() |
| 1233 | iterator begin(); |
| 1234 | |
| 1235 | //! @copydoc ::boost::container::set::begin() const |
| 1236 | const_iterator begin() const; |
| 1237 | |
| 1238 | //! @copydoc ::boost::container::set::cbegin() const |
| 1239 | const_iterator cbegin() const; |
| 1240 | |
| 1241 | //! @copydoc ::boost::container::set::end() |
| 1242 | iterator end() BOOST_NOEXCEPT_OR_NOTHROW; |
| 1243 | |
| 1244 | //! @copydoc ::boost::container::set::end() const |
| 1245 | const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 1246 | |
| 1247 | //! @copydoc ::boost::container::set::cend() const |
| 1248 | const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 1249 | |
| 1250 | //! @copydoc ::boost::container::set::rbegin() |
| 1251 | reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW; |
| 1252 | |
| 1253 | //! @copydoc ::boost::container::set::rbegin() const |
| 1254 | const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 1255 | |
| 1256 | //! @copydoc ::boost::container::set::crbegin() const |
| 1257 | const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 1258 | |
| 1259 | //! @copydoc ::boost::container::set::rend() |
| 1260 | reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW; |
| 1261 | |
| 1262 | //! @copydoc ::boost::container::set::rend() const |
| 1263 | const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 1264 | |
| 1265 | //! @copydoc ::boost::container::set::crend() const |
| 1266 | const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 1267 | |
| 1268 | //! @copydoc ::boost::container::set::empty() const |
| 1269 | bool empty() const; |
| 1270 | |
| 1271 | //! @copydoc ::boost::container::set::size() const |
| 1272 | size_type size() const; |
| 1273 | |
| 1274 | //! @copydoc ::boost::container::set::max_size() const |
| 1275 | size_type max_size() const; |
| 1276 | |
| 1277 | #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 1278 | |
| 1279 | #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 1280 | |
| 1281 | //! <b>Effects</b>: Inserts an object of type Key constructed with |
| 1282 | //! std::forward<Args>(args)... and returns the iterator pointing to the |
| 1283 | //! newly inserted element. |
| 1284 | //! |
| 1285 | //! <b>Complexity</b>: Logarithmic. |
| 1286 | template <class... Args> |
| 1287 | BOOST_CONTAINER_FORCEINLINE iterator emplace(BOOST_FWD_REF(Args)... args) |
| 1288 | { return this->base_t::emplace_equal(boost::forward<Args>(args)...); } |
| 1289 | |
| 1290 | //! <b>Effects</b>: Inserts an object of type Key constructed with |
| 1291 | //! std::forward<Args>(args)... |
| 1292 | //! |
| 1293 | //! <b>Returns</b>: An iterator pointing to the element with key equivalent |
| 1294 | //! to the key of x. |
| 1295 | //! |
| 1296 | //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t |
| 1297 | //! is inserted right before p. |
| 1298 | template <class... Args> |
| 1299 | BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args) |
| 1300 | { return this->base_t::emplace_hint_equal(p, boost::forward<Args>(args)...); } |
| 1301 | |
| 1302 | #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) |
| 1303 | |
| 1304 | #define BOOST_CONTAINER_MULTISET_EMPLACE_CODE(N) \ |
| 1305 | BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ |
| 1306 | BOOST_CONTAINER_FORCEINLINE iterator emplace(BOOST_MOVE_UREF##N)\ |
| 1307 | { return this->base_t::emplace_equal(BOOST_MOVE_FWD##N); }\ |
| 1308 | \ |
| 1309 | BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ |
| 1310 | BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ |
| 1311 | { return this->base_t::emplace_hint_equal(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\ |
| 1312 | // |
| 1313 | BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_MULTISET_EMPLACE_CODE) |
| 1314 | #undef BOOST_CONTAINER_MULTISET_EMPLACE_CODE |
| 1315 | |
| 1316 | #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) |
| 1317 | |
| 1318 | #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 1319 | //! <b>Effects</b>: Inserts x and returns the iterator pointing to the |
| 1320 | //! newly inserted element. |
| 1321 | //! |
| 1322 | //! <b>Complexity</b>: Logarithmic. |
| 1323 | iterator insert(const value_type &x); |
| 1324 | |
| 1325 | //! <b>Effects</b>: Inserts a copy of x in the container. |
| 1326 | //! |
| 1327 | //! <b>Returns</b>: An iterator pointing to the element with key equivalent |
| 1328 | //! to the key of x. |
| 1329 | //! |
| 1330 | //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t |
| 1331 | //! is inserted right before p. |
| 1332 | iterator insert(value_type &&x); |
| 1333 | #else |
| 1334 | BOOST_MOVE_CONVERSION_AWARE_CATCH(insert, value_type, iterator, this->priv_insert) |
| 1335 | #endif |
| 1336 | |
| 1337 | #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 1338 | //! <b>Effects</b>: Inserts a copy of x in the container. |
| 1339 | //! p is a hint pointing to where the insert should start to search. |
| 1340 | //! |
| 1341 | //! <b>Returns</b>: An iterator pointing to the element with key equivalent |
| 1342 | //! to the key of x. |
| 1343 | //! |
| 1344 | //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t |
| 1345 | //! is inserted right before p. |
| 1346 | iterator insert(const_iterator p, const value_type &x); |
| 1347 | |
| 1348 | //! <b>Effects</b>: Inserts a value move constructed from x in the container. |
| 1349 | //! p is a hint pointing to where the insert should start to search. |
| 1350 | //! |
| 1351 | //! <b>Returns</b>: An iterator pointing to the element with key equivalent |
| 1352 | //! to the key of x. |
| 1353 | //! |
| 1354 | //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t |
| 1355 | //! is inserted right before p. |
| 1356 | iterator insert(const_iterator p, value_type &&x); |
| 1357 | #else |
| 1358 | BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, value_type, iterator, this->priv_insert, const_iterator, const_iterator) |
| 1359 | #endif |
| 1360 | |
| 1361 | //! <b>Requires</b>: first, last are not iterators into *this. |
| 1362 | //! |
| 1363 | //! <b>Effects</b>: inserts each element from the range [first,last) . |
| 1364 | //! |
| 1365 | //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last) |
| 1366 | template <class InputIterator> |
| 1367 | BOOST_CONTAINER_FORCEINLINE void insert(InputIterator first, InputIterator last) |
| 1368 | { this->base_t::insert_equal(first, last); } |
| 1369 | |
| 1370 | #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) |
| 1371 | //! @copydoc ::boost::container::set::insert(std::initializer_list<value_type>) |
| 1372 | BOOST_CONTAINER_FORCEINLINE void insert(std::initializer_list<value_type> il) |
| 1373 | { this->base_t::insert_equal(il.begin(), il.end()); } |
| 1374 | #endif |
| 1375 | |
| 1376 | //! @copydoc ::boost::container::multimap::insert(node_type&&) |
| 1377 | BOOST_CONTAINER_FORCEINLINE iterator insert(BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh) |
| 1378 | { return this->base_t::insert_equal_node(boost::move(nh)); } |
| 1379 | |
| 1380 | //! @copydoc ::boost::container::multimap::insert(const_iterator, node_type&&) |
| 1381 | BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator hint, BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh) |
| 1382 | { return this->base_t::insert_equal_node(hint, boost::move(nh)); } |
| 1383 | |
| 1384 | //! @copydoc ::boost::container::multimap::merge(multimap<Key, T, C2, Allocator, Options>&) |
| 1385 | template<class C2> |
| 1386 | BOOST_CONTAINER_FORCEINLINE void merge(multiset<Key, C2, Allocator, Options>& source) |
| 1387 | { |
| 1388 | typedef dtl::tree |
| 1389 | <Key, dtl::identity<Key>, C2, Allocator, Options> base2_t; |
| 1390 | this->base_t::merge_equal(static_cast<base2_t&>(source)); |
| 1391 | } |
| 1392 | |
| 1393 | //! @copydoc ::boost::container::multiset::merge(multiset<Key, C2, Allocator, Options>&) |
| 1394 | template<class C2> |
| 1395 | BOOST_CONTAINER_FORCEINLINE void merge(BOOST_RV_REF_BEG multiset<Key, C2, Allocator, Options> BOOST_RV_REF_END source) |
| 1396 | { return this->merge(static_cast<multiset<Key, C2, Allocator, Options>&>(source)); } |
| 1397 | |
| 1398 | //! @copydoc ::boost::container::multimap::merge(map<Key, T, C2, Allocator, Options>&) |
| 1399 | template<class C2> |
| 1400 | BOOST_CONTAINER_FORCEINLINE void merge(set<Key, C2, Allocator, Options>& source) |
| 1401 | { |
| 1402 | typedef dtl::tree |
| 1403 | <Key, dtl::identity<Key>, C2, Allocator, Options> base2_t; |
| 1404 | this->base_t::merge_equal(static_cast<base2_t&>(source)); |
| 1405 | } |
| 1406 | |
| 1407 | //! @copydoc ::boost::container::multiset::merge(set<Key, C2, Allocator, Options>&) |
| 1408 | template<class C2> |
| 1409 | BOOST_CONTAINER_FORCEINLINE void merge(BOOST_RV_REF_BEG set<Key, C2, Allocator, Options> BOOST_RV_REF_END source) |
| 1410 | { return this->merge(static_cast<set<Key, C2, Allocator, Options>&>(source)); } |
| 1411 | |
| 1412 | #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 1413 | |
| 1414 | //! @copydoc ::boost::container::set::erase(const_iterator) |
| 1415 | iterator erase(const_iterator p); |
| 1416 | |
| 1417 | //! @copydoc ::boost::container::set::erase(const key_type&) |
| 1418 | size_type erase(const key_type& x); |
| 1419 | |
| 1420 | //! @copydoc ::boost::container::set::erase(const_iterator,const_iterator) |
| 1421 | iterator erase(const_iterator first, const_iterator last); |
| 1422 | |
| 1423 | //! @copydoc ::boost::container::multimap::extract(const_iterator) |
| 1424 | node_type extract(const_iterator p); |
| 1425 | |
| 1426 | //! @copydoc ::boost::container::multimap::extract(const key_type&) |
| 1427 | node_type extract(const key_type& x); |
| 1428 | |
| 1429 | //! @copydoc ::boost::container::set::swap |
| 1430 | void swap(multiset& x) |
| 1431 | BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value |
| 1432 | && boost::container::dtl::is_nothrow_swappable<Compare>::value ); |
| 1433 | |
| 1434 | //! @copydoc ::boost::container::set::clear |
| 1435 | void clear() BOOST_NOEXCEPT_OR_NOTHROW; |
| 1436 | |
| 1437 | //! @copydoc ::boost::container::set::key_comp |
| 1438 | key_compare key_comp() const; |
| 1439 | |
| 1440 | //! @copydoc ::boost::container::set::value_comp |
| 1441 | value_compare value_comp() const; |
| 1442 | |
| 1443 | //! @copydoc ::boost::container::set::find(const key_type& ) |
| 1444 | iterator find(const key_type& x); |
| 1445 | |
| 1446 | //! @copydoc ::boost::container::set::find(const key_type& ) const |
| 1447 | const_iterator find(const key_type& x) const; |
| 1448 | |
| 1449 | //! @copydoc ::boost::container::set::find(const K& ) |
| 1450 | template<typename K> |
| 1451 | iterator find(const K& x); |
| 1452 | |
| 1453 | //! @copydoc ::boost::container::set::find(const K& ) |
| 1454 | template<typename K> |
| 1455 | const_iterator find(const K& x) const; |
| 1456 | |
| 1457 | //! @copydoc ::boost::container::set::count(const key_type& ) const |
| 1458 | size_type count(const key_type& x) const; |
| 1459 | |
| 1460 | //! @copydoc ::boost::container::set::count(const K& ) const |
| 1461 | template<typename K> |
| 1462 | size_type count(const K& x) const; |
| 1463 | |
| 1464 | //! @copydoc ::boost::container::set::lower_bound(const key_type& ) |
| 1465 | iterator lower_bound(const key_type& x); |
| 1466 | |
| 1467 | //! @copydoc ::boost::container::set::lower_bound(const key_type& ) const |
| 1468 | const_iterator lower_bound(const key_type& x) const; |
| 1469 | |
| 1470 | //! @copydoc ::boost::container::set::lower_bound(const K& ) |
| 1471 | template<typename K> |
| 1472 | iterator lower_bound(const K& x); |
| 1473 | |
| 1474 | //! @copydoc ::boost::container::set::lower_bound(const K& ) const |
| 1475 | template<typename K> |
| 1476 | const_iterator lower_bound(const K& x) const; |
| 1477 | |
| 1478 | //! @copydoc ::boost::container::set::upper_bound(const key_type& ) |
| 1479 | iterator upper_bound(const key_type& x); |
| 1480 | |
| 1481 | //! @copydoc ::boost::container::set::upper_bound(const key_type& ) const |
| 1482 | const_iterator upper_bound(const key_type& x) const; |
| 1483 | |
| 1484 | //! @copydoc ::boost::container::set::upper_bound(const K& ) |
| 1485 | template<typename K> |
| 1486 | iterator upper_bound(const K& x); |
| 1487 | |
| 1488 | //! @copydoc ::boost::container::set::upper_bound(const K& ) const |
| 1489 | template<typename K> |
| 1490 | const_iterator upper_bound(const K& x) const; |
| 1491 | |
| 1492 | //! @copydoc ::boost::container::set::equal_range(const key_type& ) const |
| 1493 | std::pair<const_iterator, const_iterator> equal_range(const key_type& x) const; |
| 1494 | |
| 1495 | //! @copydoc ::boost::container::set::equal_range(const key_type& ) |
| 1496 | std::pair<iterator,iterator> equal_range(const key_type& x); |
| 1497 | |
| 1498 | //! @copydoc ::boost::container::set::equal_range(const K& ) const |
| 1499 | template<typename K> |
| 1500 | std::pair<const_iterator, const_iterator> equal_range(const K& x) const; |
| 1501 | |
| 1502 | //! @copydoc ::boost::container::set::equal_range(const K& ) |
| 1503 | template<typename K> |
| 1504 | std::pair<iterator,iterator> equal_range(const K& x); |
| 1505 | |
| 1506 | //! @copydoc ::boost::container::set::rebalance() |
| 1507 | void rebalance(); |
| 1508 | |
| 1509 | //! <b>Effects</b>: Returns true if x and y are equal |
| 1510 | //! |
| 1511 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 1512 | friend bool operator==(const multiset& x, const multiset& y); |
| 1513 | |
| 1514 | //! <b>Effects</b>: Returns true if x and y are unequal |
| 1515 | //! |
| 1516 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 1517 | friend bool operator!=(const multiset& x, const multiset& y); |
| 1518 | |
| 1519 | //! <b>Effects</b>: Returns true if x is less than y |
| 1520 | //! |
| 1521 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 1522 | friend bool operator<(const multiset& x, const multiset& y); |
| 1523 | |
| 1524 | //! <b>Effects</b>: Returns true if x is greater than y |
| 1525 | //! |
| 1526 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 1527 | friend bool operator>(const multiset& x, const multiset& y); |
| 1528 | |
| 1529 | //! <b>Effects</b>: Returns true if x is equal or less than y |
| 1530 | //! |
| 1531 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 1532 | friend bool operator<=(const multiset& x, const multiset& y); |
| 1533 | |
| 1534 | //! <b>Effects</b>: Returns true if x is equal or greater than y |
| 1535 | //! |
| 1536 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 1537 | friend bool operator>=(const multiset& x, const multiset& y); |
| 1538 | |
| 1539 | //! <b>Effects</b>: x.swap(y) |
| 1540 | //! |
| 1541 | //! <b>Complexity</b>: Constant. |
| 1542 | friend void swap(multiset& x, multiset& y); |
| 1543 | |
| 1544 | #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 1545 | |
| 1546 | #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 1547 | private: |
| 1548 | template <class KeyType> |
| 1549 | BOOST_CONTAINER_FORCEINLINE iterator priv_insert(BOOST_FWD_REF(KeyType) x) |
| 1550 | { return this->base_t::insert_equal(::boost::forward<KeyType>(x)); } |
| 1551 | |
| 1552 | template <class KeyType> |
| 1553 | BOOST_CONTAINER_FORCEINLINE iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x) |
| 1554 | { return this->base_t::insert_equal(p, ::boost::forward<KeyType>(x)); } |
| 1555 | |
| 1556 | #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 1557 | }; |
| 1558 | |
| 1559 | #if __cplusplus >= 201703L |
| 1560 | |
| 1561 | template <typename InputIterator> |
| 1562 | multiset(InputIterator, InputIterator) -> |
| 1563 | multiset<typename iterator_traits<InputIterator>::value_type>; |
| 1564 | |
| 1565 | template <typename InputIterator, typename Allocator> |
| 1566 | multiset(InputIterator, InputIterator, Allocator const&) -> |
| 1567 | multiset< typename iterator_traits<InputIterator>::value_type |
| 1568 | , std::less<typename iterator_traits<InputIterator>::value_type> |
| 1569 | , Allocator>; |
| 1570 | |
| 1571 | template <typename InputIterator, typename Compare> |
| 1572 | multiset(InputIterator, InputIterator, Compare const&) -> |
| 1573 | multiset<typename iterator_traits<InputIterator>::value_type, Compare>; |
| 1574 | |
| 1575 | template <typename InputIterator, typename Compare, typename Allocator> |
| 1576 | multiset(InputIterator, InputIterator, Compare const&, Allocator const&) -> |
| 1577 | multiset<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>; |
| 1578 | |
| 1579 | template <typename InputIterator> |
| 1580 | multiset(ordered_range_t, InputIterator, InputIterator) -> |
| 1581 | multiset<typename iterator_traits<InputIterator>::value_type>; |
| 1582 | |
| 1583 | template <typename InputIterator, typename Allocator> |
| 1584 | multiset(ordered_range_t, InputIterator, InputIterator, Allocator const&) -> |
| 1585 | multiset< typename iterator_traits<InputIterator>::value_type |
| 1586 | , std::less<typename iterator_traits<InputIterator>::value_type> |
| 1587 | , Allocator>; |
| 1588 | |
| 1589 | template <typename InputIterator, typename Compare> |
| 1590 | multiset(ordered_range_t, InputIterator, InputIterator, Compare const&) -> |
| 1591 | multiset< typename iterator_traits<InputIterator>::value_type, Compare>; |
| 1592 | |
| 1593 | template <typename InputIterator, typename Compare, typename Allocator> |
| 1594 | multiset(ordered_range_t, InputIterator, InputIterator, Compare const&, Allocator const&) -> |
| 1595 | multiset<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>; |
| 1596 | |
| 1597 | #endif |
| 1598 | |
| 1599 | #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 1600 | |
| 1601 | } //namespace container { |
| 1602 | |
| 1603 | //!has_trivial_destructor_after_move<> == true_type |
| 1604 | //!specialization for optimizations |
| 1605 | template <class Key, class Compare, class Allocator, class Options> |
| 1606 | struct has_trivial_destructor_after_move<boost::container::multiset<Key, Compare, Allocator, Options> > |
| 1607 | { |
| 1608 | typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer; |
| 1609 | static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value && |
| 1610 | ::boost::has_trivial_destructor_after_move<pointer>::value && |
| 1611 | ::boost::has_trivial_destructor_after_move<Compare>::value; |
| 1612 | }; |
| 1613 | |
| 1614 | namespace container { |
| 1615 | |
| 1616 | #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 1617 | |
| 1618 | }} |
| 1619 | |
| 1620 | #include <boost/container/detail/config_end.hpp> |
| 1621 | |
| 1622 | #endif // BOOST_CONTAINER_SET_HPP |