annotate DEPENDENCIES/generic/include/boost/container/set.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 //////////////////////////////////////////////////////////////////////////////
Chris@16 2 //
Chris@101 3 // (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost
Chris@16 4 // Software License, Version 1.0. (See accompanying file
Chris@16 5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6 //
Chris@16 7 // See http://www.boost.org/libs/container for documentation.
Chris@16 8 //
Chris@16 9 //////////////////////////////////////////////////////////////////////////////
Chris@16 10
Chris@16 11 #ifndef BOOST_CONTAINER_SET_HPP
Chris@16 12 #define BOOST_CONTAINER_SET_HPP
Chris@16 13
Chris@101 14 #ifndef BOOST_CONFIG_HPP
Chris@101 15 # include <boost/config.hpp>
Chris@101 16 #endif
Chris@101 17
Chris@101 18 #if defined(BOOST_HAS_PRAGMA_ONCE)
Chris@16 19 # pragma once
Chris@16 20 #endif
Chris@16 21
Chris@16 22 #include <boost/container/detail/config_begin.hpp>
Chris@16 23 #include <boost/container/detail/workaround.hpp>
Chris@101 24 // container
Chris@16 25 #include <boost/container/container_fwd.hpp>
Chris@101 26 // container/detail
Chris@16 27 #include <boost/container/detail/mpl.hpp>
Chris@16 28 #include <boost/container/detail/tree.hpp>
Chris@101 29 #include <boost/container/new_allocator.hpp> //new_allocator
Chris@101 30 // intrusive/detail
Chris@101 31 #include <boost/intrusive/detail/minimal_pair_header.hpp> //pair
Chris@101 32 #include <boost/intrusive/detail/minimal_less_equal_header.hpp>//less, equal
Chris@101 33 // move
Chris@101 34 #include <boost/move/traits.hpp>
Chris@101 35 #include <boost/move/utility_core.hpp>
Chris@101 36 // move/detail
Chris@101 37 #include <boost/move/detail/move_helpers.hpp>
Chris@101 38 #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
Chris@101 39 #include <boost/move/detail/fwd_macros.hpp>
Chris@101 40 #endif
Chris@101 41 // std
Chris@101 42 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
Chris@101 43 #include <initializer_list>
Chris@16 44 #endif
Chris@16 45
Chris@16 46 namespace boost {
Chris@16 47 namespace container {
Chris@16 48
Chris@101 49 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 50
Chris@16 51 //! A set is a kind of associative container that supports unique keys (contains at
Chris@16 52 //! most one of each key value) and provides for fast retrieval of the keys themselves.
Chris@16 53 //! Class set supports bidirectional iterators.
Chris@16 54 //!
Chris@16 55 //! A set satisfies all of the requirements of a container and of a reversible container
Chris@16 56 //! , and of an associative container. A set also provides most operations described in
Chris@16 57 //! for unique keys.
Chris@101 58 //!
Chris@101 59 //! \tparam Key is the type to be inserted in the set, which is also the key_type
Chris@101 60 //! \tparam Compare is the comparison functor used to order keys
Chris@101 61 //! \tparam Allocator is the allocator to be used to allocate memory for this container
Chris@101 62 //! \tparam SetOptions is an packed option type generated using using boost::container::tree_assoc_options.
Chris@101 63 template <class Key, class Compare = std::less<Key>, class Allocator = new_allocator<Key>, class SetOptions = tree_assoc_defaults >
Chris@16 64 #else
Chris@101 65 template <class Key, class Compare, class Allocator, class SetOptions>
Chris@16 66 #endif
Chris@16 67 class set
Chris@101 68 ///@cond
Chris@101 69 : public container_detail::tree
Chris@101 70 < Key, Key, container_detail::identity<Key>, Compare, Allocator, SetOptions>
Chris@101 71 ///@endcond
Chris@16 72 {
Chris@101 73 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 74 private:
Chris@16 75 BOOST_COPYABLE_AND_MOVABLE(set)
Chris@101 76 typedef container_detail::tree
Chris@101 77 < Key, Key, container_detail::identity<Key>, Compare, Allocator, SetOptions> base_t;
Chris@101 78 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 79
Chris@16 80 public:
Chris@16 81 //////////////////////////////////////////////
Chris@16 82 //
Chris@16 83 // types
Chris@16 84 //
Chris@16 85 //////////////////////////////////////////////
Chris@16 86 typedef Key key_type;
Chris@16 87 typedef Key value_type;
Chris@16 88 typedef Compare key_compare;
Chris@16 89 typedef Compare value_compare;
Chris@101 90 typedef ::boost::container::allocator_traits<Allocator> allocator_traits_type;
Chris@16 91 typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
Chris@16 92 typedef typename ::boost::container::allocator_traits<Allocator>::const_pointer const_pointer;
Chris@16 93 typedef typename ::boost::container::allocator_traits<Allocator>::reference reference;
Chris@16 94 typedef typename ::boost::container::allocator_traits<Allocator>::const_reference const_reference;
Chris@16 95 typedef typename ::boost::container::allocator_traits<Allocator>::size_type size_type;
Chris@16 96 typedef typename ::boost::container::allocator_traits<Allocator>::difference_type difference_type;
Chris@16 97 typedef Allocator allocator_type;
Chris@101 98 typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type;
Chris@101 99 typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator;
Chris@101 100 typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator;
Chris@101 101 typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator;
Chris@101 102 typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator;
Chris@16 103
Chris@16 104 //////////////////////////////////////////////
Chris@16 105 //
Chris@16 106 // construct/copy/destroy
Chris@16 107 //
Chris@16 108 //////////////////////////////////////////////
Chris@16 109
Chris@16 110 //! <b>Effects</b>: Default constructs an empty set.
Chris@16 111 //!
Chris@16 112 //! <b>Complexity</b>: Constant.
Chris@16 113 set()
Chris@101 114 : base_t()
Chris@16 115 {}
Chris@16 116
Chris@16 117 //! <b>Effects</b>: Constructs an empty set using the specified comparison object
Chris@16 118 //! and allocator.
Chris@16 119 //!
Chris@16 120 //! <b>Complexity</b>: Constant.
Chris@16 121 explicit set(const Compare& comp,
Chris@16 122 const allocator_type& a = allocator_type())
Chris@101 123 : base_t(comp, a)
Chris@16 124 {}
Chris@16 125
Chris@16 126 //! <b>Effects</b>: Constructs an empty set using the specified allocator object.
Chris@16 127 //!
Chris@16 128 //! <b>Complexity</b>: Constant.
Chris@16 129 explicit set(const allocator_type& a)
Chris@101 130 : base_t(a)
Chris@16 131 {}
Chris@16 132
Chris@16 133 //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
Chris@16 134 //! allocator, and inserts elements from the range [first ,last ).
Chris@16 135 //!
Chris@16 136 //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
Chris@16 137 //! comp and otherwise N logN, where N is last - first.
Chris@16 138 template <class InputIterator>
Chris@16 139 set(InputIterator first, InputIterator last, const Compare& comp = Compare(),
Chris@16 140 const allocator_type& a = allocator_type())
Chris@101 141 : base_t(true, first, last, comp, a)
Chris@101 142 {}
Chris@101 143
Chris@101 144 //! <b>Effects</b>: Constructs an empty set using the specified
Chris@101 145 //! allocator, and inserts elements from the range [first ,last ).
Chris@101 146 //!
Chris@101 147 //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
Chris@101 148 //! comp and otherwise N logN, where N is last - first.
Chris@101 149 template <class InputIterator>
Chris@101 150 set(InputIterator first, InputIterator last, const allocator_type& a)
Chris@101 151 : base_t(true, first, last, key_compare(), a)
Chris@16 152 {}
Chris@16 153
Chris@16 154 //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
Chris@16 155 //! allocator, and inserts elements from the ordered unique range [first ,last). This function
Chris@16 156 //! is more efficient than the normal range creation for ordered ranges.
Chris@16 157 //!
Chris@16 158 //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
Chris@16 159 //! unique values.
Chris@16 160 //!
Chris@16 161 //! <b>Complexity</b>: Linear in N.
Chris@16 162 //!
Chris@16 163 //! <b>Note</b>: Non-standard extension.
Chris@16 164 template <class InputIterator>
Chris@16 165 set( ordered_unique_range_t, InputIterator first, InputIterator last
Chris@16 166 , const Compare& comp = Compare(), const allocator_type& a = allocator_type())
Chris@101 167 : base_t(ordered_range, first, last, comp, a)
Chris@16 168 {}
Chris@16 169
Chris@101 170 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
Chris@101 171 //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
Chris@101 172 //! allocator, and inserts elements from the range [il.begin(), il.end()).
Chris@101 173 //!
Chris@101 174 //! <b>Complexity</b>: Linear in N if the range [il.begin(), il.end()) is already sorted using
Chris@101 175 //! comp and otherwise N logN, where N is il.begin() - il.end().
Chris@101 176 set(std::initializer_list<value_type> il, const Compare& comp = Compare(), const allocator_type& a = allocator_type())
Chris@101 177 : base_t(true, il.begin(), il.end(), comp, a)
Chris@101 178 {}
Chris@101 179
Chris@101 180 //! <b>Effects</b>: Constructs an empty set using the specified
Chris@101 181 //! allocator, and inserts elements from the range [il.begin(), il.end()).
Chris@101 182 //!
Chris@101 183 //! <b>Complexity</b>: Linear in N if the range [il.begin(), il.end()) is already sorted using
Chris@101 184 //! comp and otherwise N logN, where N is il.begin() - il.end().
Chris@101 185 set(std::initializer_list<value_type> il, const allocator_type& a)
Chris@101 186 : base_t(true, il.begin(), il.end(), Compare(), a)
Chris@101 187 {}
Chris@101 188
Chris@101 189 //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
Chris@101 190 //! allocator, and inserts elements from the ordered unique range [il.begin(), il.end()). This function
Chris@101 191 //! is more efficient than the normal range creation for ordered ranges.
Chris@101 192 //!
Chris@101 193 //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be
Chris@101 194 //! unique values.
Chris@101 195 //!
Chris@101 196 //! <b>Complexity</b>: Linear in N.
Chris@101 197 //!
Chris@101 198 //! <b>Note</b>: Non-standard extension.
Chris@101 199 set( ordered_unique_range_t, std::initializer_list<value_type> il, const Compare& comp = Compare()
Chris@101 200 , const allocator_type& a = allocator_type())
Chris@101 201 : base_t(ordered_range, il.begin(), il.end(), comp, a)
Chris@101 202 {}
Chris@101 203 #endif
Chris@101 204
Chris@16 205 //! <b>Effects</b>: Copy constructs a set.
Chris@16 206 //!
Chris@16 207 //! <b>Complexity</b>: Linear in x.size().
Chris@16 208 set(const set& x)
Chris@101 209 : base_t(static_cast<const base_t&>(x))
Chris@16 210 {}
Chris@16 211
Chris@16 212 //! <b>Effects</b>: Move constructs a set. Constructs *this using x's resources.
Chris@16 213 //!
Chris@16 214 //! <b>Complexity</b>: Constant.
Chris@16 215 //!
Chris@16 216 //! <b>Postcondition</b>: x is emptied.
Chris@16 217 set(BOOST_RV_REF(set) x)
Chris@101 218 : base_t(BOOST_MOVE_BASE(base_t, x))
Chris@16 219 {}
Chris@16 220
Chris@16 221 //! <b>Effects</b>: Copy constructs a set using the specified allocator.
Chris@16 222 //!
Chris@16 223 //! <b>Complexity</b>: Linear in x.size().
Chris@16 224 set(const set& x, const allocator_type &a)
Chris@101 225 : base_t(static_cast<const base_t&>(x), a)
Chris@16 226 {}
Chris@16 227
Chris@16 228 //! <b>Effects</b>: Move constructs a set using the specified allocator.
Chris@16 229 //! Constructs *this using x's resources.
Chris@16 230 //!
Chris@16 231 //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise.
Chris@16 232 set(BOOST_RV_REF(set) x, const allocator_type &a)
Chris@101 233 : base_t(BOOST_MOVE_BASE(base_t, x), a)
Chris@16 234 {}
Chris@16 235
Chris@16 236 //! <b>Effects</b>: Makes *this a copy of x.
Chris@16 237 //!
Chris@16 238 //! <b>Complexity</b>: Linear in x.size().
Chris@16 239 set& operator=(BOOST_COPY_ASSIGN_REF(set) x)
Chris@101 240 { return static_cast<set&>(this->base_t::operator=(static_cast<const base_t&>(x))); }
Chris@16 241
Chris@16 242 //! <b>Effects</b>: this->swap(x.get()).
Chris@16 243 //!
Chris@101 244 //! <b>Throws</b>: If allocator_traits_type::propagate_on_container_move_assignment
Chris@101 245 //! is false and (allocation throws or value_type's move constructor throws)
Chris@101 246 //!
Chris@101 247 //! <b>Complexity</b>: Constant if allocator_traits_type::
Chris@101 248 //! propagate_on_container_move_assignment is true or
Chris@101 249 //! this->get>allocator() == x.get_allocator(). Linear otherwise.
Chris@16 250 set& operator=(BOOST_RV_REF(set) x)
Chris@101 251 BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
Chris@101 252 && boost::container::container_detail::is_nothrow_move_assignable<Compare>::value )
Chris@101 253 { return static_cast<set&>(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); }
Chris@16 254
Chris@101 255 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
Chris@101 256 set& operator=(std::initializer_list<value_type> il)
Chris@101 257 {
Chris@101 258 this->clear();
Chris@101 259 insert(il.begin(), il.end());
Chris@101 260 return *this;
Chris@101 261 }
Chris@101 262 #endif
Chris@101 263
Chris@101 264 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@101 265
Chris@101 266 //! <b>Effects</b>: Returns a copy of the allocator that
Chris@16 267 //! was passed to the object's constructor.
Chris@16 268 //!
Chris@16 269 //! <b>Complexity</b>: Constant.
Chris@101 270 allocator_type get_allocator() const;
Chris@16 271
Chris@16 272 //! <b>Effects</b>: Returns a reference to the internal allocator.
Chris@16 273 //!
Chris@16 274 //! <b>Throws</b>: Nothing
Chris@16 275 //!
Chris@16 276 //! <b>Complexity</b>: Constant.
Chris@16 277 //!
Chris@16 278 //! <b>Note</b>: Non-standard extension.
Chris@101 279 stored_allocator_type &get_stored_allocator();
Chris@16 280
Chris@16 281 //! <b>Effects</b>: Returns a reference to the internal allocator.
Chris@16 282 //!
Chris@16 283 //! <b>Throws</b>: Nothing
Chris@16 284 //!
Chris@16 285 //! <b>Complexity</b>: Constant.
Chris@16 286 //!
Chris@16 287 //! <b>Note</b>: Non-standard extension.
Chris@101 288 const stored_allocator_type &get_stored_allocator() const;
Chris@16 289
Chris@16 290 //! <b>Effects</b>: Returns an iterator to the first element contained in the container.
Chris@16 291 //!
Chris@16 292 //! <b>Throws</b>: Nothing.
Chris@16 293 //!
Chris@16 294 //! <b>Complexity</b>: Constant
Chris@101 295 iterator begin();
Chris@16 296
Chris@16 297 //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
Chris@16 298 //!
Chris@16 299 //! <b>Throws</b>: Nothing.
Chris@16 300 //!
Chris@16 301 //! <b>Complexity</b>: Constant.
Chris@101 302 const_iterator begin() const;
Chris@101 303
Chris@101 304 //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
Chris@101 305 //!
Chris@101 306 //! <b>Throws</b>: Nothing.
Chris@101 307 //!
Chris@101 308 //! <b>Complexity</b>: Constant.
Chris@101 309 const_iterator cbegin() const;
Chris@16 310
Chris@16 311 //! <b>Effects</b>: Returns an iterator to the end of the container.
Chris@16 312 //!
Chris@16 313 //! <b>Throws</b>: Nothing.
Chris@16 314 //!
Chris@16 315 //! <b>Complexity</b>: Constant.
Chris@101 316 iterator end();
Chris@16 317
Chris@16 318 //! <b>Effects</b>: Returns a const_iterator to the end of the container.
Chris@16 319 //!
Chris@16 320 //! <b>Throws</b>: Nothing.
Chris@16 321 //!
Chris@16 322 //! <b>Complexity</b>: Constant.
Chris@101 323 const_iterator end() const;
Chris@101 324
Chris@101 325 //! <b>Effects</b>: Returns a const_iterator to the end of the container.
Chris@101 326 //!
Chris@101 327 //! <b>Throws</b>: Nothing.
Chris@101 328 //!
Chris@101 329 //! <b>Complexity</b>: Constant.
Chris@101 330 const_iterator cend() const;
Chris@16 331
Chris@16 332 //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
Chris@16 333 //! of the reversed container.
Chris@16 334 //!
Chris@16 335 //! <b>Throws</b>: Nothing.
Chris@16 336 //!
Chris@16 337 //! <b>Complexity</b>: Constant.
Chris@101 338 reverse_iterator rbegin();
Chris@16 339
Chris@16 340 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
Chris@16 341 //! of the reversed container.
Chris@16 342 //!
Chris@16 343 //! <b>Throws</b>: Nothing.
Chris@16 344 //!
Chris@16 345 //! <b>Complexity</b>: Constant.
Chris@101 346 const_reverse_iterator rbegin() const;
Chris@101 347
Chris@101 348 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
Chris@101 349 //! of the reversed container.
Chris@101 350 //!
Chris@101 351 //! <b>Throws</b>: Nothing.
Chris@101 352 //!
Chris@101 353 //! <b>Complexity</b>: Constant.
Chris@101 354 const_reverse_iterator crbegin() const;
Chris@16 355
Chris@16 356 //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
Chris@16 357 //! of the reversed container.
Chris@16 358 //!
Chris@16 359 //! <b>Throws</b>: Nothing.
Chris@16 360 //!
Chris@16 361 //! <b>Complexity</b>: Constant.
Chris@101 362 reverse_iterator rend();
Chris@16 363
Chris@16 364 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
Chris@16 365 //! of the reversed container.
Chris@16 366 //!
Chris@16 367 //! <b>Throws</b>: Nothing.
Chris@16 368 //!
Chris@16 369 //! <b>Complexity</b>: Constant.
Chris@101 370 const_reverse_iterator rend() const;
Chris@16 371
Chris@16 372 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
Chris@16 373 //! of the reversed container.
Chris@16 374 //!
Chris@16 375 //! <b>Throws</b>: Nothing.
Chris@16 376 //!
Chris@16 377 //! <b>Complexity</b>: Constant.
Chris@101 378 const_reverse_iterator crend() const;
Chris@16 379
Chris@16 380 //! <b>Effects</b>: Returns true if the container contains no elements.
Chris@16 381 //!
Chris@16 382 //! <b>Throws</b>: Nothing.
Chris@16 383 //!
Chris@16 384 //! <b>Complexity</b>: Constant.
Chris@101 385 bool empty() const;
Chris@16 386
Chris@16 387 //! <b>Effects</b>: Returns the number of the elements contained in the container.
Chris@16 388 //!
Chris@16 389 //! <b>Throws</b>: Nothing.
Chris@16 390 //!
Chris@16 391 //! <b>Complexity</b>: Constant.
Chris@101 392 size_type size() const;
Chris@16 393
Chris@16 394 //! <b>Effects</b>: Returns the largest possible size of the container.
Chris@16 395 //!
Chris@16 396 //! <b>Throws</b>: Nothing.
Chris@16 397 //!
Chris@16 398 //! <b>Complexity</b>: Constant.
Chris@101 399 size_type max_size() const;
Chris@101 400 #endif // #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 401
Chris@101 402 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 403
Chris@16 404 //! <b>Effects</b>: Inserts an object x of type Key constructed with
Chris@16 405 //! std::forward<Args>(args)... if and only if there is
Chris@16 406 //! no element in the container with equivalent value.
Chris@16 407 //! and returns the iterator pointing to the
Chris@16 408 //! newly inserted element.
Chris@16 409 //!
Chris@16 410 //! <b>Returns</b>: The bool component of the returned pair is true if and only
Chris@16 411 //! if the insertion takes place, and the iterator component of the pair
Chris@16 412 //! points to the element with key equivalent to the key of x.
Chris@16 413 //!
Chris@16 414 //! <b>Throws</b>: If memory allocation throws or
Chris@16 415 //! Key's in-place constructor throws.
Chris@16 416 //!
Chris@16 417 //! <b>Complexity</b>: Logarithmic.
Chris@16 418 template <class... Args>
Chris@101 419 std::pair<iterator,bool> emplace(BOOST_FWD_REF(Args)... args)
Chris@101 420 { return this->base_t::emplace_unique(boost::forward<Args>(args)...); }
Chris@16 421
Chris@16 422 //! <b>Effects</b>: Inserts an object of type Key constructed with
Chris@16 423 //! std::forward<Args>(args)... if and only if there is
Chris@16 424 //! no element in the container with equivalent value.
Chris@16 425 //! p is a hint pointing to where the insert
Chris@16 426 //! should start to search.
Chris@16 427 //!
Chris@16 428 //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x.
Chris@16 429 //!
Chris@16 430 //! <b>Complexity</b>: Logarithmic.
Chris@16 431 template <class... Args>
Chris@101 432 iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args)
Chris@101 433 { return this->base_t::emplace_hint_unique(p, boost::forward<Args>(args)...); }
Chris@16 434
Chris@101 435 #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
Chris@16 436
Chris@101 437 #define BOOST_CONTAINER_SET_EMPLACE_CODE(N) \
Chris@101 438 BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
Chris@101 439 std::pair<iterator,bool> emplace(BOOST_MOVE_UREF##N)\
Chris@101 440 { return this->base_t::emplace_unique(BOOST_MOVE_FWD##N); }\
Chris@101 441 \
Chris@101 442 BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
Chris@101 443 iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
Chris@101 444 { return this->base_t::emplace_hint_unique(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\
Chris@101 445 //
Chris@101 446 BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_SET_EMPLACE_CODE)
Chris@101 447 #undef BOOST_CONTAINER_SET_EMPLACE_CODE
Chris@16 448
Chris@101 449 #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
Chris@16 450
Chris@16 451 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 452 //! <b>Effects</b>: Inserts x if and only if there is no element in the container
Chris@16 453 //! with key equivalent to the key of x.
Chris@16 454 //!
Chris@16 455 //! <b>Returns</b>: The bool component of the returned pair is true if and only
Chris@16 456 //! if the insertion takes place, and the iterator component of the pair
Chris@16 457 //! points to the element with key equivalent to the key of x.
Chris@16 458 //!
Chris@16 459 //! <b>Complexity</b>: Logarithmic.
Chris@16 460 std::pair<iterator, bool> insert(const value_type &x);
Chris@16 461
Chris@16 462 //! <b>Effects</b>: Move constructs a new value from x if and only if there is
Chris@16 463 //! no element in the container with key equivalent to the key of x.
Chris@16 464 //!
Chris@16 465 //! <b>Returns</b>: The bool component of the returned pair is true if and only
Chris@16 466 //! if the insertion takes place, and the iterator component of the pair
Chris@16 467 //! points to the element with key equivalent to the key of x.
Chris@16 468 //!
Chris@16 469 //! <b>Complexity</b>: Logarithmic.
Chris@16 470 std::pair<iterator, bool> insert(value_type &&x);
Chris@16 471 #else
Chris@16 472 private:
Chris@16 473 typedef std::pair<iterator, bool> insert_return_pair;
Chris@16 474 public:
Chris@16 475 BOOST_MOVE_CONVERSION_AWARE_CATCH(insert, value_type, insert_return_pair, this->priv_insert)
Chris@16 476 #endif
Chris@16 477
Chris@16 478 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 479 //! <b>Effects</b>: Inserts a copy of x in the container if and only if there is
Chris@16 480 //! no element in the container with key equivalent to the key of x.
Chris@16 481 //! p is a hint pointing to where the insert should start to search.
Chris@16 482 //!
Chris@16 483 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
Chris@16 484 //! to the key of x.
Chris@16 485 //!
Chris@16 486 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
Chris@16 487 //! is inserted right before p.
Chris@16 488 iterator insert(const_iterator p, const value_type &x);
Chris@16 489
Chris@16 490 //! <b>Effects</b>: Inserts an element move constructed from x in the container.
Chris@16 491 //! p is a hint pointing to where the insert should start to search.
Chris@16 492 //!
Chris@16 493 //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x.
Chris@16 494 //!
Chris@16 495 //! <b>Complexity</b>: Logarithmic.
Chris@101 496 iterator insert(const_iterator p, value_type &&x);
Chris@16 497 #else
Chris@16 498 BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, value_type, iterator, this->priv_insert, const_iterator, const_iterator)
Chris@16 499 #endif
Chris@16 500
Chris@16 501 //! <b>Requires</b>: first, last are not iterators into *this.
Chris@16 502 //!
Chris@16 503 //! <b>Effects</b>: inserts each element from the range [first,last) if and only
Chris@16 504 //! if there is no element with key equivalent to the key of that element.
Chris@16 505 //!
Chris@16 506 //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
Chris@16 507 template <class InputIterator>
Chris@16 508 void insert(InputIterator first, InputIterator last)
Chris@101 509 { this->base_t::insert_unique(first, last); }
Chris@101 510
Chris@101 511 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
Chris@101 512 //! <b>Effects</b>: inserts each element from the range [il.begin(),il.end()) if and only
Chris@101 513 //! if there is no element with key equivalent to the key of that element.
Chris@101 514 //!
Chris@101 515 //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from il.begin() to il.end())
Chris@101 516 void insert(std::initializer_list<value_type> il)
Chris@101 517 { this->base_t::insert_unique(il.begin(), il.end()); }
Chris@101 518 #endif
Chris@101 519
Chris@101 520 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 521
Chris@16 522 //! <b>Effects</b>: Erases the element pointed to by p.
Chris@16 523 //!
Chris@16 524 //! <b>Returns</b>: Returns an iterator pointing to the element immediately
Chris@16 525 //! following q prior to the element being erased. If no such element exists,
Chris@16 526 //! returns end().
Chris@16 527 //!
Chris@16 528 //! <b>Complexity</b>: Amortized constant time
Chris@101 529 iterator erase(const_iterator p);
Chris@16 530
Chris@16 531 //! <b>Effects</b>: Erases all elements in the container with key equivalent to x.
Chris@16 532 //!
Chris@16 533 //! <b>Returns</b>: Returns the number of erased elements.
Chris@16 534 //!
Chris@16 535 //! <b>Complexity</b>: log(size()) + count(k)
Chris@101 536 size_type erase(const key_type& x);
Chris@16 537
Chris@16 538 //! <b>Effects</b>: Erases all the elements in the range [first, last).
Chris@16 539 //!
Chris@16 540 //! <b>Returns</b>: Returns last.
Chris@16 541 //!
Chris@16 542 //! <b>Complexity</b>: log(size())+N where N is the distance from first to last.
Chris@101 543 iterator erase(const_iterator first, const_iterator last);
Chris@16 544
Chris@16 545 //! <b>Effects</b>: Swaps the contents of *this and x.
Chris@16 546 //!
Chris@16 547 //! <b>Throws</b>: Nothing.
Chris@16 548 //!
Chris@16 549 //! <b>Complexity</b>: Constant.
Chris@16 550 void swap(set& x)
Chris@101 551 BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
Chris@101 552 && boost::container::container_detail::is_nothrow_swappable<Compare>::value );
Chris@16 553
Chris@16 554 //! <b>Effects</b>: erase(a.begin(),a.end()).
Chris@16 555 //!
Chris@16 556 //! <b>Postcondition</b>: size() == 0.
Chris@16 557 //!
Chris@16 558 //! <b>Complexity</b>: linear in size().
Chris@101 559 void clear();
Chris@16 560
Chris@16 561 //! <b>Effects</b>: Returns the comparison object out
Chris@16 562 //! of which a was constructed.
Chris@16 563 //!
Chris@16 564 //! <b>Complexity</b>: Constant.
Chris@101 565 key_compare key_comp() const;
Chris@16 566
Chris@16 567 //! <b>Effects</b>: Returns an object of value_compare constructed out
Chris@16 568 //! of the comparison object.
Chris@16 569 //!
Chris@16 570 //! <b>Complexity</b>: Constant.
Chris@101 571 value_compare value_comp() const;
Chris@16 572
Chris@16 573 //! <b>Returns</b>: An iterator pointing to an element with the key
Chris@16 574 //! equivalent to x, or end() if such an element is not found.
Chris@16 575 //!
Chris@16 576 //! <b>Complexity</b>: Logarithmic.
Chris@101 577 iterator find(const key_type& x);
Chris@16 578
Chris@101 579 //! <b>Returns</b>: A const_iterator pointing to an element with the key
Chris@16 580 //! equivalent to x, or end() if such an element is not found.
Chris@16 581 //!
Chris@16 582 //! <b>Complexity</b>: Logarithmic.
Chris@101 583 const_iterator find(const key_type& x) const;
Chris@101 584
Chris@101 585 #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 586
Chris@16 587 //! <b>Returns</b>: The number of elements with key equivalent to x.
Chris@16 588 //!
Chris@16 589 //! <b>Complexity</b>: log(size())+count(k)
Chris@16 590 size_type count(const key_type& x) const
Chris@101 591 { return static_cast<size_type>(this->base_t::find(x) != this->base_t::cend()); }
Chris@101 592
Chris@101 593 //! <b>Returns</b>: The number of elements with key equivalent to x.
Chris@101 594 //!
Chris@101 595 //! <b>Complexity</b>: log(size())+count(k)
Chris@101 596 size_type count(const key_type& x)
Chris@101 597 { return static_cast<size_type>(this->base_t::find(x) != this->base_t::end()); }
Chris@101 598
Chris@101 599 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 600
Chris@16 601 //! <b>Returns</b>: An iterator pointing to the first element with key not less
Chris@16 602 //! than k, or a.end() if such an element is not found.
Chris@16 603 //!
Chris@16 604 //! <b>Complexity</b>: Logarithmic
Chris@101 605 iterator lower_bound(const key_type& x);
Chris@16 606
Chris@101 607 //! <b>Returns</b>: A const iterator pointing to the first element with key not
Chris@16 608 //! less than k, or a.end() if such an element is not found.
Chris@16 609 //!
Chris@16 610 //! <b>Complexity</b>: Logarithmic
Chris@101 611 const_iterator lower_bound(const key_type& x) const;
Chris@16 612
Chris@16 613 //! <b>Returns</b>: An iterator pointing to the first element with key not less
Chris@16 614 //! than x, or end() if such an element is not found.
Chris@16 615 //!
Chris@16 616 //! <b>Complexity</b>: Logarithmic
Chris@101 617 iterator upper_bound(const key_type& x);
Chris@16 618
Chris@101 619 //! <b>Returns</b>: A const iterator pointing to the first element with key not
Chris@16 620 //! less than x, or end() if such an element is not found.
Chris@16 621 //!
Chris@16 622 //! <b>Complexity</b>: Logarithmic
Chris@101 623 const_iterator upper_bound(const key_type& x) const;
Chris@101 624
Chris@101 625 #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 626
Chris@16 627 //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
Chris@16 628 //!
Chris@16 629 //! <b>Complexity</b>: Logarithmic
Chris@16 630 std::pair<iterator,iterator> equal_range(const key_type& x)
Chris@101 631 { return this->base_t::lower_bound_range(x); }
Chris@16 632
Chris@16 633 //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
Chris@16 634 //!
Chris@16 635 //! <b>Complexity</b>: Logarithmic
Chris@16 636 std::pair<const_iterator, const_iterator> equal_range(const key_type& x) const
Chris@101 637 { return this->base_t::lower_bound_range(x); }
Chris@16 638
Chris@101 639 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 640
Chris@101 641 //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
Chris@101 642 //!
Chris@101 643 //! <b>Complexity</b>: Logarithmic
Chris@101 644 std::pair<iterator,iterator> equal_range(const key_type& x);
Chris@16 645
Chris@101 646 //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
Chris@101 647 //!
Chris@101 648 //! <b>Complexity</b>: Logarithmic
Chris@101 649 std::pair<const_iterator, const_iterator> equal_range(const key_type& x) const;
Chris@101 650
Chris@101 651 //! <b>Effects</b>: Rebalances the tree. It's a no-op for Red-Black and AVL trees.
Chris@101 652 //!
Chris@101 653 //! <b>Complexity</b>: Linear
Chris@101 654 void rebalance();
Chris@101 655
Chris@101 656 //! <b>Effects</b>: Returns true if x and y are equal
Chris@101 657 //!
Chris@101 658 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 659 friend bool operator==(const set& x, const set& y);
Chris@101 660
Chris@101 661 //! <b>Effects</b>: Returns true if x and y are unequal
Chris@101 662 //!
Chris@101 663 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 664 friend bool operator!=(const set& x, const set& y);
Chris@101 665
Chris@101 666 //! <b>Effects</b>: Returns true if x is less than y
Chris@101 667 //!
Chris@101 668 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 669 friend bool operator<(const set& x, const set& y);
Chris@101 670
Chris@101 671 //! <b>Effects</b>: Returns true if x is greater than y
Chris@101 672 //!
Chris@101 673 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 674 friend bool operator>(const set& x, const set& y);
Chris@101 675
Chris@101 676 //! <b>Effects</b>: Returns true if x is equal or less than y
Chris@101 677 //!
Chris@101 678 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 679 friend bool operator<=(const set& x, const set& y);
Chris@101 680
Chris@101 681 //! <b>Effects</b>: Returns true if x is equal or greater than y
Chris@101 682 //!
Chris@101 683 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 684 friend bool operator>=(const set& x, const set& y);
Chris@101 685
Chris@101 686 //! <b>Effects</b>: x.swap(y)
Chris@101 687 //!
Chris@101 688 //! <b>Complexity</b>: Constant.
Chris@101 689 friend void swap(set& x, set& y);
Chris@101 690
Chris@101 691 #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@101 692
Chris@101 693 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 694 private:
Chris@16 695 template <class KeyType>
Chris@16 696 std::pair<iterator, bool> priv_insert(BOOST_FWD_REF(KeyType) x)
Chris@101 697 { return this->base_t::insert_unique(::boost::forward<KeyType>(x)); }
Chris@16 698
Chris@16 699 template <class KeyType>
Chris@16 700 iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x)
Chris@101 701 { return this->base_t::insert_unique(p, ::boost::forward<KeyType>(x)); }
Chris@101 702 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 703 };
Chris@16 704
Chris@101 705 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 706
Chris@16 707 } //namespace container {
Chris@16 708
Chris@16 709 //!has_trivial_destructor_after_move<> == true_type
Chris@16 710 //!specialization for optimizations
Chris@101 711 template <class Key, class Compare, class SetOptions, class Allocator>
Chris@101 712 struct has_trivial_destructor_after_move<boost::container::set<Key, Compare, Allocator, SetOptions> >
Chris@16 713 {
Chris@101 714 typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
Chris@101 715 static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
Chris@101 716 ::boost::has_trivial_destructor_after_move<pointer>::value &&
Chris@101 717 ::boost::has_trivial_destructor_after_move<Compare>::value;
Chris@16 718 };
Chris@16 719
Chris@16 720 namespace container {
Chris@16 721
Chris@101 722 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 723
Chris@101 724 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 725
Chris@16 726 //! A multiset is a kind of associative container that supports equivalent keys
Chris@16 727 //! (possibly contains multiple copies of the same key value) and provides for
Chris@16 728 //! fast retrieval of the keys themselves. Class multiset supports bidirectional iterators.
Chris@16 729 //!
Chris@16 730 //! A multiset satisfies all of the requirements of a container and of a reversible
Chris@16 731 //! container, and of an associative container). multiset also provides most operations
Chris@16 732 //! described for duplicate keys.
Chris@101 733 //!
Chris@101 734 //! \tparam Key is the type to be inserted in the set, which is also the key_type
Chris@101 735 //! \tparam Compare is the comparison functor used to order keys
Chris@101 736 //! \tparam Allocator is the allocator to be used to allocate memory for this container
Chris@101 737 //! \tparam MultiSetOptions is an packed option type generated using using boost::container::tree_assoc_options.
Chris@101 738 template <class Key, class Compare = std::less<Key>, class Allocator = new_allocator<Key>, class MultiSetOptions = tree_assoc_defaults >
Chris@16 739 #else
Chris@101 740 template <class Key, class Compare, class Allocator, class MultiSetOptions>
Chris@16 741 #endif
Chris@16 742 class multiset
Chris@101 743 /// @cond
Chris@101 744 : public container_detail::tree
Chris@101 745 <Key, Key,container_detail::identity<Key>, Compare, Allocator, MultiSetOptions>
Chris@101 746 /// @endcond
Chris@16 747 {
Chris@101 748 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 749 private:
Chris@16 750 BOOST_COPYABLE_AND_MOVABLE(multiset)
Chris@101 751 typedef container_detail::tree
Chris@101 752 <Key, Key,container_detail::identity<Key>, Compare, Allocator, MultiSetOptions> base_t;
Chris@101 753 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 754
Chris@16 755 public:
Chris@16 756
Chris@16 757 //////////////////////////////////////////////
Chris@16 758 //
Chris@16 759 // types
Chris@16 760 //
Chris@16 761 //////////////////////////////////////////////
Chris@16 762 typedef Key key_type;
Chris@16 763 typedef Key value_type;
Chris@16 764 typedef Compare key_compare;
Chris@16 765 typedef Compare value_compare;
Chris@101 766 typedef ::boost::container::allocator_traits<Allocator> allocator_traits_type;
Chris@16 767 typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
Chris@16 768 typedef typename ::boost::container::allocator_traits<Allocator>::const_pointer const_pointer;
Chris@16 769 typedef typename ::boost::container::allocator_traits<Allocator>::reference reference;
Chris@16 770 typedef typename ::boost::container::allocator_traits<Allocator>::const_reference const_reference;
Chris@16 771 typedef typename ::boost::container::allocator_traits<Allocator>::size_type size_type;
Chris@16 772 typedef typename ::boost::container::allocator_traits<Allocator>::difference_type difference_type;
Chris@16 773 typedef Allocator allocator_type;
Chris@101 774 typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type;
Chris@101 775 typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator;
Chris@101 776 typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator;
Chris@101 777 typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator;
Chris@101 778 typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator;
Chris@16 779
Chris@16 780 //////////////////////////////////////////////
Chris@16 781 //
Chris@16 782 // construct/copy/destroy
Chris@16 783 //
Chris@16 784 //////////////////////////////////////////////
Chris@16 785
Chris@101 786 //! @copydoc ::boost::container::set::set()
Chris@16 787 multiset()
Chris@101 788 : base_t()
Chris@16 789 {}
Chris@16 790
Chris@101 791 //! @copydoc ::boost::container::set::set(const Compare&, const allocator_type&)
Chris@16 792 explicit multiset(const Compare& comp,
Chris@16 793 const allocator_type& a = allocator_type())
Chris@101 794 : base_t(comp, a)
Chris@16 795 {}
Chris@16 796
Chris@101 797 //! @copydoc ::boost::container::set::set(const allocator_type&)
Chris@16 798 explicit multiset(const allocator_type& a)
Chris@101 799 : base_t(a)
Chris@16 800 {}
Chris@16 801
Chris@101 802 //! @copydoc ::boost::container::set::set(InputIterator, InputIterator, const Compare& comp, const allocator_type&)
Chris@16 803 template <class InputIterator>
Chris@16 804 multiset(InputIterator first, InputIterator last,
Chris@16 805 const Compare& comp = Compare(),
Chris@16 806 const allocator_type& a = allocator_type())
Chris@101 807 : base_t(false, first, last, comp, a)
Chris@101 808 {}
Chris@101 809
Chris@101 810 //! @copydoc ::boost::container::set::set(InputIterator, InputIterator, const allocator_type&)
Chris@101 811 template <class InputIterator>
Chris@101 812 multiset(InputIterator first, InputIterator last, const allocator_type& a)
Chris@101 813 : base_t(false, first, last, key_compare(), a)
Chris@16 814 {}
Chris@16 815
Chris@16 816 //! <b>Effects</b>: Constructs an empty multiset using the specified comparison object and
Chris@16 817 //! allocator, and inserts elements from the ordered range [first ,last ). This function
Chris@16 818 //! is more efficient than the normal range creation for ordered ranges.
Chris@16 819 //!
Chris@16 820 //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
Chris@16 821 //!
Chris@16 822 //! <b>Complexity</b>: Linear in N.
Chris@16 823 //!
Chris@16 824 //! <b>Note</b>: Non-standard extension.
Chris@16 825 template <class InputIterator>
Chris@16 826 multiset( ordered_range_t, InputIterator first, InputIterator last
Chris@16 827 , const Compare& comp = Compare()
Chris@16 828 , const allocator_type& a = allocator_type())
Chris@101 829 : base_t(ordered_range, first, last, comp, a)
Chris@16 830 {}
Chris@16 831
Chris@101 832 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
Chris@101 833 //! @copydoc ::boost::container::set::set(std::initializer_list<value_type>, const Compare& comp, const allocator_type&)
Chris@101 834 multiset(std::initializer_list<value_type> il, const Compare& comp = Compare(), const allocator_type& a = allocator_type())
Chris@101 835 : base_t(false, il.begin(), il.end(), comp, a)
Chris@16 836 {}
Chris@16 837
Chris@101 838 //! @copydoc ::boost::container::set::set(std::initializer_list<value_type>, const allocator_type&)
Chris@101 839 multiset(std::initializer_list<value_type> il, const allocator_type& a)
Chris@101 840 : base_t(false, il.begin(), il.end(), Compare(), a)
Chris@16 841 {}
Chris@16 842
Chris@101 843 //! @copydoc ::boost::container::set::set(ordered_unique_range_t, std::initializer_list<value_type>, const Compare& comp, const allocator_type&)
Chris@101 844 multiset(ordered_unique_range_t, std::initializer_list<value_type> il, const Compare& comp = Compare(), const allocator_type& a = allocator_type())
Chris@101 845 : base_t(ordered_range, il.begin(), il.end(), comp, a)
Chris@101 846 {}
Chris@101 847 #endif
Chris@101 848
Chris@101 849 //! @copydoc ::boost::container::set::set(const set &)
Chris@101 850 multiset(const multiset& x)
Chris@101 851 : base_t(static_cast<const base_t&>(x))
Chris@16 852 {}
Chris@16 853
Chris@101 854 //! @copydoc ::boost::container::set(set &&)
Chris@101 855 multiset(BOOST_RV_REF(multiset) x)
Chris@101 856 : base_t(BOOST_MOVE_BASE(base_t, x))
Chris@16 857 {}
Chris@16 858
Chris@101 859 //! @copydoc ::boost::container::set(const set &, const allocator_type &)
Chris@101 860 multiset(const multiset& x, const allocator_type &a)
Chris@101 861 : base_t(static_cast<const base_t&>(x), a)
Chris@101 862 {}
Chris@101 863
Chris@101 864 //! @copydoc ::boost::container::set(set &&, const allocator_type &)
Chris@101 865 multiset(BOOST_RV_REF(multiset) x, const allocator_type &a)
Chris@101 866 : base_t(BOOST_MOVE_BASE(base_t, x), a)
Chris@101 867 {}
Chris@101 868
Chris@101 869 //! @copydoc ::boost::container::set::operator=(const set &)
Chris@16 870 multiset& operator=(BOOST_COPY_ASSIGN_REF(multiset) x)
Chris@101 871 { return static_cast<multiset&>(this->base_t::operator=(static_cast<const base_t&>(x))); }
Chris@16 872
Chris@101 873 //! @copydoc ::boost::container::set::operator=(set &&)
Chris@16 874 multiset& operator=(BOOST_RV_REF(multiset) x)
Chris@101 875 BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
Chris@101 876 && boost::container::container_detail::is_nothrow_move_assignable<Compare>::value )
Chris@101 877 { return static_cast<multiset&>(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); }
Chris@16 878
Chris@101 879 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
Chris@101 880 //! @copydoc ::boost::container::set::operator=(std::initializer_list<value_type>)
Chris@101 881 multiset& operator=(std::initializer_list<value_type> il)
Chris@101 882 {
Chris@101 883 this->clear();
Chris@101 884 insert(il.begin(), il.end());
Chris@101 885 return *this;
Chris@101 886 }
Chris@101 887 #endif
Chris@101 888 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 889
Chris@101 890 //! @copydoc ::boost::container::set::get_allocator()
Chris@101 891 allocator_type get_allocator() const;
Chris@16 892
Chris@101 893 //! @copydoc ::boost::container::set::get_stored_allocator()
Chris@101 894 stored_allocator_type &get_stored_allocator();
Chris@16 895
Chris@101 896 //! @copydoc ::boost::container::set::get_stored_allocator() const
Chris@101 897 const stored_allocator_type &get_stored_allocator() const;
Chris@16 898
Chris@101 899 //! @copydoc ::boost::container::set::begin()
Chris@101 900 iterator begin();
Chris@16 901
Chris@101 902 //! @copydoc ::boost::container::set::begin() const
Chris@101 903 const_iterator begin() const;
Chris@16 904
Chris@101 905 //! @copydoc ::boost::container::set::cbegin() const
Chris@101 906 const_iterator cbegin() const;
Chris@16 907
Chris@101 908 //! @copydoc ::boost::container::set::end()
Chris@101 909 iterator end() BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 910
Chris@101 911 //! @copydoc ::boost::container::set::end() const
Chris@101 912 const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 913
Chris@101 914 //! @copydoc ::boost::container::set::cend() const
Chris@101 915 const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 916
Chris@101 917 //! @copydoc ::boost::container::set::rbegin()
Chris@101 918 reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 919
Chris@101 920 //! @copydoc ::boost::container::set::rbegin() const
Chris@101 921 const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 922
Chris@101 923 //! @copydoc ::boost::container::set::crbegin() const
Chris@101 924 const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 925
Chris@101 926 //! @copydoc ::boost::container::set::rend()
Chris@101 927 reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 928
Chris@101 929 //! @copydoc ::boost::container::set::rend() const
Chris@101 930 const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 931
Chris@101 932 //! @copydoc ::boost::container::set::crend() const
Chris@101 933 const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 934
Chris@101 935 //! @copydoc ::boost::container::set::empty() const
Chris@101 936 bool empty() const;
Chris@16 937
Chris@101 938 //! @copydoc ::boost::container::set::size() const
Chris@101 939 size_type size() const;
Chris@16 940
Chris@101 941 //! @copydoc ::boost::container::set::max_size() const
Chris@101 942 size_type max_size() const;
Chris@16 943
Chris@101 944 #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 945
Chris@101 946 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 947
Chris@16 948 //! <b>Effects</b>: Inserts an object of type Key constructed with
Chris@16 949 //! std::forward<Args>(args)... and returns the iterator pointing to the
Chris@16 950 //! newly inserted element.
Chris@16 951 //!
Chris@16 952 //! <b>Complexity</b>: Logarithmic.
Chris@16 953 template <class... Args>
Chris@101 954 iterator emplace(BOOST_FWD_REF(Args)... args)
Chris@101 955 { return this->base_t::emplace_equal(boost::forward<Args>(args)...); }
Chris@16 956
Chris@16 957 //! <b>Effects</b>: Inserts an object of type Key constructed with
Chris@16 958 //! std::forward<Args>(args)...
Chris@16 959 //!
Chris@16 960 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
Chris@16 961 //! to the key of x.
Chris@16 962 //!
Chris@16 963 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
Chris@16 964 //! is inserted right before p.
Chris@16 965 template <class... Args>
Chris@101 966 iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args)
Chris@101 967 { return this->base_t::emplace_hint_equal(p, boost::forward<Args>(args)...); }
Chris@16 968
Chris@101 969 #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
Chris@16 970
Chris@101 971 #define BOOST_CONTAINER_MULTISET_EMPLACE_CODE(N) \
Chris@101 972 BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
Chris@101 973 iterator emplace(BOOST_MOVE_UREF##N)\
Chris@101 974 { return this->base_t::emplace_equal(BOOST_MOVE_FWD##N); }\
Chris@101 975 \
Chris@101 976 BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
Chris@101 977 iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
Chris@101 978 { return this->base_t::emplace_hint_equal(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\
Chris@101 979 //
Chris@101 980 BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_MULTISET_EMPLACE_CODE)
Chris@101 981 #undef BOOST_CONTAINER_MULTISET_EMPLACE_CODE
Chris@16 982
Chris@101 983 #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
Chris@16 984
Chris@16 985 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 986 //! <b>Effects</b>: Inserts x and returns the iterator pointing to the
Chris@16 987 //! newly inserted element.
Chris@16 988 //!
Chris@16 989 //! <b>Complexity</b>: Logarithmic.
Chris@16 990 iterator insert(const value_type &x);
Chris@16 991
Chris@16 992 //! <b>Effects</b>: Inserts a copy of x in the container.
Chris@16 993 //!
Chris@16 994 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
Chris@16 995 //! to the key of x.
Chris@16 996 //!
Chris@16 997 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
Chris@16 998 //! is inserted right before p.
Chris@16 999 iterator insert(value_type &&x);
Chris@16 1000 #else
Chris@16 1001 BOOST_MOVE_CONVERSION_AWARE_CATCH(insert, value_type, iterator, this->priv_insert)
Chris@16 1002 #endif
Chris@16 1003
Chris@16 1004 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 1005 //! <b>Effects</b>: Inserts a copy of x in the container.
Chris@16 1006 //! p is a hint pointing to where the insert should start to search.
Chris@16 1007 //!
Chris@16 1008 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
Chris@16 1009 //! to the key of x.
Chris@16 1010 //!
Chris@16 1011 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
Chris@16 1012 //! is inserted right before p.
Chris@16 1013 iterator insert(const_iterator p, const value_type &x);
Chris@16 1014
Chris@16 1015 //! <b>Effects</b>: Inserts a value move constructed from x in the container.
Chris@16 1016 //! p is a hint pointing to where the insert should start to search.
Chris@16 1017 //!
Chris@16 1018 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
Chris@16 1019 //! to the key of x.
Chris@16 1020 //!
Chris@16 1021 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
Chris@16 1022 //! is inserted right before p.
Chris@101 1023 iterator insert(const_iterator p, value_type &&x);
Chris@16 1024 #else
Chris@16 1025 BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, value_type, iterator, this->priv_insert, const_iterator, const_iterator)
Chris@16 1026 #endif
Chris@16 1027
Chris@16 1028 //! <b>Requires</b>: first, last are not iterators into *this.
Chris@16 1029 //!
Chris@16 1030 //! <b>Effects</b>: inserts each element from the range [first,last) .
Chris@16 1031 //!
Chris@16 1032 //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
Chris@16 1033 template <class InputIterator>
Chris@16 1034 void insert(InputIterator first, InputIterator last)
Chris@101 1035 { this->base_t::insert_equal(first, last); }
Chris@16 1036
Chris@101 1037 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
Chris@101 1038 //! @copydoc ::boost::container::set::insert(std::initializer_list<value_type>)
Chris@101 1039 void insert(std::initializer_list<value_type> il)
Chris@101 1040 { this->base_t::insert_equal(il.begin(), il.end()); }
Chris@101 1041 #endif
Chris@101 1042
Chris@101 1043 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@101 1044
Chris@101 1045 //! @copydoc ::boost::container::set::erase(const_iterator)
Chris@101 1046 iterator erase(const_iterator p);
Chris@101 1047
Chris@101 1048 //! @copydoc ::boost::container::set::erase(const key_type&)
Chris@101 1049 size_type erase(const key_type& x);
Chris@101 1050
Chris@101 1051 //! @copydoc ::boost::container::set::erase(const_iterator,const_iterator)
Chris@101 1052 iterator erase(const_iterator first, const_iterator last);
Chris@101 1053
Chris@101 1054 //! @copydoc ::boost::container::set::swap
Chris@101 1055 void swap(multiset& x)
Chris@101 1056 BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
Chris@101 1057 && boost::container::container_detail::is_nothrow_swappable<Compare>::value );
Chris@101 1058
Chris@101 1059 //! @copydoc ::boost::container::set::clear
Chris@101 1060 void clear() BOOST_NOEXCEPT_OR_NOTHROW;
Chris@101 1061
Chris@101 1062 //! @copydoc ::boost::container::set::key_comp
Chris@101 1063 key_compare key_comp() const;
Chris@101 1064
Chris@101 1065 //! @copydoc ::boost::container::set::value_comp
Chris@101 1066 value_compare value_comp() const;
Chris@101 1067
Chris@101 1068 //! @copydoc ::boost::container::set::find(const key_type& )
Chris@101 1069 iterator find(const key_type& x);
Chris@101 1070
Chris@101 1071 //! @copydoc ::boost::container::set::find(const key_type& ) const
Chris@101 1072 const_iterator find(const key_type& x) const;
Chris@101 1073
Chris@101 1074 //! @copydoc ::boost::container::set::count(const key_type& ) const
Chris@101 1075 size_type count(const key_type& x) const;
Chris@101 1076
Chris@101 1077 //! @copydoc ::boost::container::set::lower_bound(const key_type& )
Chris@101 1078 iterator lower_bound(const key_type& x);
Chris@101 1079
Chris@101 1080 //! @copydoc ::boost::container::set::lower_bound(const key_type& ) const
Chris@101 1081 const_iterator lower_bound(const key_type& x) const;
Chris@101 1082
Chris@101 1083 //! @copydoc ::boost::container::set::upper_bound(const key_type& )
Chris@101 1084 iterator upper_bound(const key_type& x);
Chris@101 1085
Chris@101 1086 //! @copydoc ::boost::container::set::upper_bound(const key_type& ) const
Chris@101 1087 const_iterator upper_bound(const key_type& x) const;
Chris@101 1088
Chris@101 1089 //! @copydoc ::boost::container::set::equal_range(const key_type& ) const
Chris@101 1090 std::pair<const_iterator, const_iterator> equal_range(const key_type& x) const;
Chris@101 1091
Chris@101 1092 //! @copydoc ::boost::container::set::equal_range(const key_type& )
Chris@101 1093 std::pair<iterator,iterator> equal_range(const key_type& x);
Chris@101 1094
Chris@101 1095 //! @copydoc ::boost::container::set::rebalance()
Chris@101 1096 void rebalance();
Chris@101 1097
Chris@101 1098 //! <b>Effects</b>: Returns true if x and y are equal
Chris@16 1099 //!
Chris@101 1100 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 1101 friend bool operator==(const multiset& x, const multiset& y);
Chris@101 1102
Chris@101 1103 //! <b>Effects</b>: Returns true if x and y are unequal
Chris@16 1104 //!
Chris@101 1105 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 1106 friend bool operator!=(const multiset& x, const multiset& y);
Chris@16 1107
Chris@101 1108 //! <b>Effects</b>: Returns true if x is less than y
Chris@16 1109 //!
Chris@101 1110 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 1111 friend bool operator<(const multiset& x, const multiset& y);
Chris@101 1112
Chris@101 1113 //! <b>Effects</b>: Returns true if x is greater than y
Chris@16 1114 //!
Chris@101 1115 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 1116 friend bool operator>(const multiset& x, const multiset& y);
Chris@16 1117
Chris@101 1118 //! <b>Effects</b>: Returns true if x is equal or less than y
Chris@16 1119 //!
Chris@101 1120 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 1121 friend bool operator<=(const multiset& x, const multiset& y);
Chris@101 1122
Chris@101 1123 //! <b>Effects</b>: Returns true if x is equal or greater than y
Chris@16 1124 //!
Chris@101 1125 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 1126 friend bool operator>=(const multiset& x, const multiset& y);
Chris@16 1127
Chris@101 1128 //! <b>Effects</b>: x.swap(y)
Chris@16 1129 //!
Chris@16 1130 //! <b>Complexity</b>: Constant.
Chris@101 1131 friend void swap(multiset& x, multiset& y);
Chris@16 1132
Chris@101 1133 #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 1134
Chris@101 1135 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 1136 private:
Chris@16 1137 template <class KeyType>
Chris@16 1138 iterator priv_insert(BOOST_FWD_REF(KeyType) x)
Chris@101 1139 { return this->base_t::insert_equal(::boost::forward<KeyType>(x)); }
Chris@16 1140
Chris@16 1141 template <class KeyType>
Chris@16 1142 iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x)
Chris@101 1143 { return this->base_t::insert_equal(p, ::boost::forward<KeyType>(x)); }
Chris@16 1144
Chris@101 1145 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 1146 };
Chris@16 1147
Chris@101 1148 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 1149
Chris@16 1150 } //namespace container {
Chris@16 1151
Chris@16 1152 //!has_trivial_destructor_after_move<> == true_type
Chris@16 1153 //!specialization for optimizations
Chris@101 1154 template <class Key, class Compare, class Allocator, class MultiSetOptions>
Chris@101 1155 struct has_trivial_destructor_after_move<boost::container::multiset<Key, Compare, Allocator, MultiSetOptions> >
Chris@16 1156 {
Chris@101 1157 typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
Chris@101 1158 static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
Chris@101 1159 ::boost::has_trivial_destructor_after_move<pointer>::value &&
Chris@101 1160 ::boost::has_trivial_destructor_after_move<Compare>::value;
Chris@16 1161 };
Chris@16 1162
Chris@16 1163 namespace container {
Chris@16 1164
Chris@101 1165 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 1166
Chris@16 1167 }}
Chris@16 1168
Chris@16 1169 #include <boost/container/detail/config_end.hpp>
Chris@16 1170
Chris@101 1171 #endif // BOOST_CONTAINER_SET_HPP