1 //////////////////////////////////////////////////////////////////////////////
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)
7 // See http://www.boost.org/libs/container for documentation.
9 //////////////////////////////////////////////////////////////////////////////
11 #ifndef BOOST_CONTAINER_SET_HPP
12 #define BOOST_CONTAINER_SET_HPP
14 #ifndef BOOST_CONFIG_HPP
15 # include <boost/config.hpp>
18 #if defined(BOOST_HAS_PRAGMA_ONCE)
22 #include <boost/container/detail/config_begin.hpp>
23 #include <boost/container/detail/workaround.hpp>
25 #include <boost/container/container_fwd.hpp>
27 #include <boost/container/detail/mpl.hpp>
28 #include <boost/container/detail/tree.hpp>
29 #include <boost/container/new_allocator.hpp> //new_allocator
31 #include <boost/intrusive/detail/minimal_pair_header.hpp> //pair
32 #include <boost/intrusive/detail/minimal_less_equal_header.hpp>//less, equal
34 #include <boost/move/traits.hpp>
35 #include <boost/move/utility_core.hpp>
37 #include <boost/move/detail/move_helpers.hpp>
38 #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
39 #include <boost/move/detail/fwd_macros.hpp>
42 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
43 #include <initializer_list>
49 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
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.
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
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>
65 template <class Key, class Compare, class Allocator, class Options>
70 < Key, dtl::identity<Key>, Compare, Allocator, Options>
73 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
75 BOOST_COPYABLE_AND_MOVABLE(set)
77 < Key, dtl::identity<Key>, Compare, Allocator, Options> base_t;
78 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
81 //////////////////////////////////////////////
85 //////////////////////////////////////////////
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;
106 //////////////////////////////////////////////
108 // construct/copy/destroy
110 //////////////////////////////////////////////
112 //! <b>Effects</b>: Default constructs an empty set.
114 //! <b>Complexity</b>: Constant.
116 BOOST_CONTAINER_FORCEINLINE set()
117 BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible<Allocator>::value &&
118 dtl::is_nothrow_default_constructible<Compare>::value)
122 //! <b>Effects</b>: Constructs an empty set using the specified allocator object.
124 //! <b>Complexity</b>: Constant.
125 BOOST_CONTAINER_FORCEINLINE explicit set(const allocator_type& a)
129 //! <b>Effects</b>: Constructs an empty set using the specified comparison object.
131 //! <b>Complexity</b>: Constant.
132 BOOST_CONTAINER_FORCEINLINE explicit set(const Compare& comp)
136 //! <b>Effects</b>: Constructs an empty set using the specified comparison object
139 //! <b>Complexity</b>: Constant.
140 BOOST_CONTAINER_FORCEINLINE set(const Compare& comp, const allocator_type& a)
144 //! <b>Effects</b>: Constructs an empty set using and
145 //! inserts elements from the range [first ,last ).
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)
154 //! <b>Effects</b>: Constructs an empty set using the specified
155 //! allocator, and inserts elements from the range [first ,last ).
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)
164 //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
165 //! inserts elements from the range [first ,last ).
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)
174 //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
175 //! allocator, and inserts elements from the range [first ,last ).
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)
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.
188 //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
191 //! <b>Complexity</b>: Linear in N.
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)
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.
203 //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
206 //! <b>Complexity</b>: Linear in N.
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)
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.
218 //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
221 //! <b>Complexity</b>: Linear in N.
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)
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()).
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())
240 //! <b>Effects</b>: Constructs an empty set using the specified
241 //! allocator, and inserts elements from the range [il.begin(), il.end()).
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)
249 //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
250 //! inserts elements from the range [il.begin(), il.end()).
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)
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()).
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)
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.
271 //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be
274 //! <b>Complexity</b>: Linear in N.
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())
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.
285 //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be
288 //! <b>Complexity</b>: Linear in N.
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)
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.
299 //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be
302 //! <b>Complexity</b>: Linear in N.
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)
310 //! <b>Effects</b>: Copy constructs a set.
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))
317 //! <b>Effects</b>: Move constructs a set. Constructs *this using x's resources.
319 //! <b>Complexity</b>: Constant.
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))
327 //! <b>Effects</b>: Copy constructs a set using the specified allocator.
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)
334 //! <b>Effects</b>: Move constructs a set using the specified allocator.
335 //! Constructs *this using x's resources.
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)
342 //! <b>Effects</b>: Makes *this a copy of x.
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))); }
348 //! <b>Effects</b>: this->swap(x.get()).
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)
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))); }
362 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
363 //! <b>Effects</b>: Copy all elements from il to *this.
365 //! <b>Complexity</b>: Linear in il.size().
366 set& operator=(std::initializer_list<value_type> il)
369 insert(il.begin(), il.end());
374 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
376 //! <b>Effects</b>: Returns a copy of the allocator that
377 //! was passed to the object's constructor.
379 //! <b>Complexity</b>: Constant.
380 allocator_type get_allocator() const;
382 //! <b>Effects</b>: Returns a reference to the internal allocator.
384 //! <b>Throws</b>: Nothing
386 //! <b>Complexity</b>: Constant.
388 //! <b>Note</b>: Non-standard extension.
389 stored_allocator_type &get_stored_allocator();
391 //! <b>Effects</b>: Returns a reference to the internal allocator.
393 //! <b>Throws</b>: Nothing
395 //! <b>Complexity</b>: Constant.
397 //! <b>Note</b>: Non-standard extension.
398 const stored_allocator_type &get_stored_allocator() const;
400 //! <b>Effects</b>: Returns an iterator to the first element contained in the container.
402 //! <b>Throws</b>: Nothing.
404 //! <b>Complexity</b>: Constant
407 //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
409 //! <b>Throws</b>: Nothing.
411 //! <b>Complexity</b>: Constant.
412 const_iterator begin() const;
414 //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
416 //! <b>Throws</b>: Nothing.
418 //! <b>Complexity</b>: Constant.
419 const_iterator cbegin() const;
421 //! <b>Effects</b>: Returns an iterator to the end of the container.
423 //! <b>Throws</b>: Nothing.
425 //! <b>Complexity</b>: Constant.
428 //! <b>Effects</b>: Returns a const_iterator to the end of the container.
430 //! <b>Throws</b>: Nothing.
432 //! <b>Complexity</b>: Constant.
433 const_iterator end() const;
435 //! <b>Effects</b>: Returns a const_iterator to the end of the container.
437 //! <b>Throws</b>: Nothing.
439 //! <b>Complexity</b>: Constant.
440 const_iterator cend() const;
442 //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
443 //! of the reversed container.
445 //! <b>Throws</b>: Nothing.
447 //! <b>Complexity</b>: Constant.
448 reverse_iterator rbegin();
450 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
451 //! of the reversed container.
453 //! <b>Throws</b>: Nothing.
455 //! <b>Complexity</b>: Constant.
456 const_reverse_iterator rbegin() const;
458 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
459 //! of the reversed container.
461 //! <b>Throws</b>: Nothing.
463 //! <b>Complexity</b>: Constant.
464 const_reverse_iterator crbegin() const;
466 //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
467 //! of the reversed container.
469 //! <b>Throws</b>: Nothing.
471 //! <b>Complexity</b>: Constant.
472 reverse_iterator rend();
474 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
475 //! of the reversed container.
477 //! <b>Throws</b>: Nothing.
479 //! <b>Complexity</b>: Constant.
480 const_reverse_iterator rend() const;
482 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
483 //! of the reversed container.
485 //! <b>Throws</b>: Nothing.
487 //! <b>Complexity</b>: Constant.
488 const_reverse_iterator crend() const;
490 //! <b>Effects</b>: Returns true if the container contains no elements.
492 //! <b>Throws</b>: Nothing.
494 //! <b>Complexity</b>: Constant.
497 //! <b>Effects</b>: Returns the number of the elements contained in the container.
499 //! <b>Throws</b>: Nothing.
501 //! <b>Complexity</b>: Constant.
502 size_type size() const;
504 //! <b>Effects</b>: Returns the largest possible size of the container.
506 //! <b>Throws</b>: Nothing.
508 //! <b>Complexity</b>: Constant.
509 size_type max_size() const;
510 #endif // #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
512 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
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.
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.
524 //! <b>Throws</b>: If memory allocation throws or
525 //! Key's in-place constructor throws.
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)...); }
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.
538 //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x.
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)...); }
545 #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
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); }\
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); }\
556 BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_SET_EMPLACE_CODE)
557 #undef BOOST_CONTAINER_SET_EMPLACE_CODE
559 #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
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.
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.
569 //! <b>Complexity</b>: Logarithmic.
570 std::pair<iterator, bool> insert(const value_type &x);
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.
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.
579 //! <b>Complexity</b>: Logarithmic.
580 std::pair<iterator, bool> insert(value_type &&x);
583 typedef std::pair<iterator, bool> insert_return_pair;
585 BOOST_MOVE_CONVERSION_AWARE_CATCH(insert, value_type, insert_return_pair, this->priv_insert)
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.
593 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
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);
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.
603 //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x.
605 //! <b>Complexity</b>: Logarithmic.
606 iterator insert(const_iterator p, value_type &&x);
608 BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, value_type, iterator, this->priv_insert, const_iterator, const_iterator)
611 //! <b>Requires</b>: first, last are not iterators into *this.
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.
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); }
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.
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()); }
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)); }
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)); }
638 //! @copydoc ::boost::container::map::merge(map<Key, T, C2, Allocator, Options>&)
640 BOOST_CONTAINER_FORCEINLINE void merge(set<Key, C2, Allocator, Options>& source)
643 <Key, dtl::identity<Key>, C2, Allocator, Options> base2_t;
644 this->base_t::merge_unique(static_cast<base2_t&>(source));
647 //! @copydoc ::boost::container::set::merge(set<Key, C2, Allocator, Options>&)
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)); }
652 //! @copydoc ::boost::container::map::merge(multimap<Key, T, C2, Allocator, Options>&)
654 BOOST_CONTAINER_FORCEINLINE void merge(multiset<Key, C2, Allocator, Options>& source)
657 <Key, dtl::identity<Key>, C2, Allocator, Options> base2_t;
658 this->base_t::merge_unique(static_cast<base2_t&>(source));
661 //! @copydoc ::boost::container::set::merge(multiset<Key, C2, Allocator, Options>&)
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)); }
666 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
668 //! <b>Effects</b>: Erases the element pointed to by p.
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,
674 //! <b>Complexity</b>: Amortized constant time
675 iterator erase(const_iterator p);
677 //! <b>Effects</b>: Erases all elements in the container with key equivalent to x.
679 //! <b>Returns</b>: Returns the number of erased elements.
681 //! <b>Complexity</b>: log(size()) + count(k)
682 size_type erase(const key_type& x);
684 //! <b>Effects</b>: Erases all the elements in the range [first, last).
686 //! <b>Returns</b>: Returns last.
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);
691 //! @copydoc ::boost::container::map::extract(const_iterator)
692 node_type extract(const_iterator p);
694 //! @copydoc ::boost::container::map::extract(const key_type&)
695 node_type extract(const key_type& x);
697 //! <b>Effects</b>: Swaps the contents of *this and x.
699 //! <b>Throws</b>: Nothing.
701 //! <b>Complexity</b>: Constant.
703 BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
704 && boost::container::dtl::is_nothrow_swappable<Compare>::value );
706 //! <b>Effects</b>: erase(a.begin(),a.end()).
708 //! <b>Postcondition</b>: size() == 0.
710 //! <b>Complexity</b>: linear in size().
713 //! <b>Effects</b>: Returns the comparison object out
714 //! of which a was constructed.
716 //! <b>Complexity</b>: Constant.
717 key_compare key_comp() const;
719 //! <b>Effects</b>: Returns an object of value_compare constructed out
720 //! of the comparison object.
722 //! <b>Complexity</b>: Constant.
723 value_compare value_comp() const;
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.
728 //! <b>Complexity</b>: Logarithmic.
729 iterator find(const key_type& x);
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.
734 //! <b>Complexity</b>: Logarithmic.
735 const_iterator find(const key_type& x) const;
737 #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
739 //! <b>Returns</b>: The number of elements with key equivalent to x.
741 //! <b>Complexity</b>: log(size())+count(k)
742 BOOST_CONTAINER_FORCEINLINE size_type count(const key_type& x) const
743 { return static_cast<size_type>(this->base_t::find(x) != this->base_t::cend()); }
745 //! <b>Returns</b>: The number of elements with key equivalent to x.
747 //! <b>Complexity</b>: log(size())+count(k)
748 BOOST_CONTAINER_FORCEINLINE size_type count(const key_type& x)
749 { return static_cast<size_type>(this->base_t::find(x) != this->base_t::end()); }
751 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
753 //! <b>Returns</b>: An iterator pointing to the first element with key not less
754 //! than k, or a.end() if such an element is not found.
756 //! <b>Complexity</b>: Logarithmic
757 iterator lower_bound(const key_type& x);
759 //! <b>Returns</b>: A const iterator pointing to the first element with key not
760 //! less than k, or a.end() if such an element is not found.
762 //! <b>Complexity</b>: Logarithmic
763 const_iterator lower_bound(const key_type& x) const;
765 //! <b>Returns</b>: An iterator pointing to the first element with key not less
766 //! than x, or end() if such an element is not found.
768 //! <b>Complexity</b>: Logarithmic
769 iterator upper_bound(const key_type& x);
771 //! <b>Returns</b>: A const iterator pointing to the first element with key not
772 //! less than x, or end() if such an element is not found.
774 //! <b>Complexity</b>: Logarithmic
775 const_iterator upper_bound(const key_type& x) const;
777 #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
779 //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
781 //! <b>Complexity</b>: Logarithmic
782 BOOST_CONTAINER_FORCEINLINE std::pair<iterator,iterator> equal_range(const key_type& x)
783 { return this->base_t::lower_bound_range(x); }
785 //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
787 //! <b>Complexity</b>: Logarithmic
788 BOOST_CONTAINER_FORCEINLINE std::pair<const_iterator, const_iterator> equal_range(const key_type& x) const
789 { return this->base_t::lower_bound_range(x); }
791 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
793 //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
795 //! <b>Complexity</b>: Logarithmic
796 std::pair<iterator,iterator> equal_range(const key_type& x);
798 //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
800 //! <b>Complexity</b>: Logarithmic
801 std::pair<const_iterator, const_iterator> equal_range(const key_type& x) const;
803 //! <b>Effects</b>: Rebalances the tree. It's a no-op for Red-Black and AVL trees.
805 //! <b>Complexity</b>: Linear
808 //! <b>Effects</b>: Returns true if x and y are equal
810 //! <b>Complexity</b>: Linear to the number of elements in the container.
811 friend bool operator==(const set& x, const set& y);
813 //! <b>Effects</b>: Returns true if x and y are unequal
815 //! <b>Complexity</b>: Linear to the number of elements in the container.
816 friend bool operator!=(const set& x, const set& y);
818 //! <b>Effects</b>: Returns true if x is less than y
820 //! <b>Complexity</b>: Linear to the number of elements in the container.
821 friend bool operator<(const set& x, const set& y);
823 //! <b>Effects</b>: Returns true if x is greater than y
825 //! <b>Complexity</b>: Linear to the number of elements in the container.
826 friend bool operator>(const set& x, const set& y);
828 //! <b>Effects</b>: Returns true if x is equal or less than y
830 //! <b>Complexity</b>: Linear to the number of elements in the container.
831 friend bool operator<=(const set& x, const set& y);
833 //! <b>Effects</b>: Returns true if x is equal or greater than y
835 //! <b>Complexity</b>: Linear to the number of elements in the container.
836 friend bool operator>=(const set& x, const set& y);
838 //! <b>Effects</b>: x.swap(y)
840 //! <b>Complexity</b>: Constant.
841 friend void swap(set& x, set& y);
843 #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
845 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
847 template <class KeyType>
848 BOOST_CONTAINER_FORCEINLINE std::pair<iterator, bool> priv_insert(BOOST_FWD_REF(KeyType) x)
849 { return this->base_t::insert_unique(::boost::forward<KeyType>(x)); }
851 template <class KeyType>
852 BOOST_CONTAINER_FORCEINLINE iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x)
853 { return this->base_t::insert_unique(p, ::boost::forward<KeyType>(x)); }
854 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
857 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
859 } //namespace container {
861 //!has_trivial_destructor_after_move<> == true_type
862 //!specialization for optimizations
863 template <class Key, class Compare, class Options, class Allocator>
864 struct has_trivial_destructor_after_move<boost::container::set<Key, Compare, Allocator, Options> >
866 typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
867 static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
868 ::boost::has_trivial_destructor_after_move<pointer>::value &&
869 ::boost::has_trivial_destructor_after_move<Compare>::value;
872 namespace container {
874 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
876 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
878 //! A multiset is a kind of associative container that supports equivalent keys
879 //! (possibly contains multiple copies of the same key value) and provides for
880 //! fast retrieval of the keys themselves. Class multiset supports bidirectional iterators.
882 //! A multiset satisfies all of the requirements of a container and of a reversible
883 //! container, and of an associative container). multiset also provides most operations
884 //! described for duplicate keys.
886 //! \tparam Key is the type to be inserted in the set, which is also the key_type
887 //! \tparam Compare is the comparison functor used to order keys
888 //! \tparam Allocator is the allocator to be used to allocate memory for this container
889 //! \tparam Options is an packed option type generated using using boost::container::tree_assoc_options.
890 template <class Key, class Compare = std::less<Key>, class Allocator = new_allocator<Key>, class Options = tree_assoc_defaults >
892 template <class Key, class Compare, class Allocator, class Options>
897 <Key,dtl::identity<Key>, Compare, Allocator, Options>
900 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
902 BOOST_COPYABLE_AND_MOVABLE(multiset)
904 <Key,dtl::identity<Key>, Compare, Allocator, Options> base_t;
905 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
909 //////////////////////////////////////////////
913 //////////////////////////////////////////////
914 typedef Key key_type;
915 typedef Key value_type;
916 typedef Compare key_compare;
917 typedef Compare value_compare;
918 typedef ::boost::container::allocator_traits<Allocator> allocator_traits_type;
919 typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
920 typedef typename ::boost::container::allocator_traits<Allocator>::const_pointer const_pointer;
921 typedef typename ::boost::container::allocator_traits<Allocator>::reference reference;
922 typedef typename ::boost::container::allocator_traits<Allocator>::const_reference const_reference;
923 typedef typename ::boost::container::allocator_traits<Allocator>::size_type size_type;
924 typedef typename ::boost::container::allocator_traits<Allocator>::difference_type difference_type;
925 typedef Allocator allocator_type;
926 typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type;
927 typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator;
928 typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator;
929 typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator;
930 typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator;
931 typedef typename BOOST_CONTAINER_IMPDEF(base_t::node_type) node_type;
933 //////////////////////////////////////////////
935 // construct/copy/destroy
937 //////////////////////////////////////////////
939 //! @copydoc ::boost::container::set::set()
940 BOOST_CONTAINER_FORCEINLINE multiset()
941 BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible<Allocator>::value &&
942 dtl::is_nothrow_default_constructible<Compare>::value)
946 //! @copydoc ::boost::container::set::set(const allocator_type&)
947 BOOST_CONTAINER_FORCEINLINE explicit multiset(const allocator_type& a)
951 //! @copydoc ::boost::container::set::set(const Compare&)
952 BOOST_CONTAINER_FORCEINLINE explicit multiset(const Compare& comp)
956 //! @copydoc ::boost::container::set::set(const Compare&, const allocator_type&)
957 BOOST_CONTAINER_FORCEINLINE multiset(const Compare& comp, const allocator_type& a)
961 //! @copydoc ::boost::container::set::set(InputIterator, InputIterator)
962 template <class InputIterator>
963 BOOST_CONTAINER_FORCEINLINE multiset(InputIterator first, InputIterator last)
964 : base_t(false, first, last)
967 //! @copydoc ::boost::container::set::set(InputIterator, InputIterator, const allocator_type&)
968 template <class InputIterator>
969 BOOST_CONTAINER_FORCEINLINE multiset(InputIterator first, InputIterator last, const allocator_type& a)
970 : base_t(false, first, last, key_compare(), a)
973 //! @copydoc ::boost::container::set::set(InputIterator, InputIterator, const Compare&)
974 template <class InputIterator>
975 BOOST_CONTAINER_FORCEINLINE multiset(InputIterator first, InputIterator last, const Compare& comp)
976 : base_t(false, first, last, comp)
979 //! @copydoc ::boost::container::set::set(InputIterator, InputIterator, const Compare&, const allocator_type&)
980 template <class InputIterator>
981 BOOST_CONTAINER_FORCEINLINE multiset(InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a)
982 : base_t(false, first, last, comp, a)
985 //! <b>Effects</b>: Constructs an empty multiset and
986 //! and inserts elements from the ordered range [first ,last ). This function
987 //! is more efficient than the normal range creation for ordered ranges.
989 //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
991 //! <b>Complexity</b>: Linear in N.
993 //! <b>Note</b>: Non-standard extension.
994 template <class InputIterator>
995 BOOST_CONTAINER_FORCEINLINE multiset( ordered_range_t, InputIterator first, InputIterator last )
996 : base_t(ordered_range, first, last)
999 //! <b>Effects</b>: Constructs an empty multiset using the specified comparison object and
1000 //! inserts elements from the ordered range [first ,last ). This function
1001 //! is more efficient than the normal range creation for ordered ranges.
1003 //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
1005 //! <b>Complexity</b>: Linear in N.
1007 //! <b>Note</b>: Non-standard extension.
1008 template <class InputIterator>
1009 BOOST_CONTAINER_FORCEINLINE multiset( ordered_range_t, InputIterator first, InputIterator last, const Compare& comp)
1010 : base_t(ordered_range, first, last, comp)
1013 //! <b>Effects</b>: Constructs an empty multiset using the specified comparison object and
1014 //! allocator, and inserts elements from the ordered range [first ,last ). This function
1015 //! is more efficient than the normal range creation for ordered ranges.
1017 //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
1019 //! <b>Complexity</b>: Linear in N.
1021 //! <b>Note</b>: Non-standard extension.
1022 template <class InputIterator>
1023 BOOST_CONTAINER_FORCEINLINE multiset( ordered_range_t, InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a)
1024 : base_t(ordered_range, first, last, comp, a)
1027 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
1028 //! @copydoc ::boost::container::set::set(std::initializer_list<value_type>)
1029 BOOST_CONTAINER_FORCEINLINE multiset(std::initializer_list<value_type> il)
1030 : base_t(false, il.begin(), il.end())
1033 //! @copydoc ::boost::container::set::set(std::initializer_list<value_type>, const allocator_type&)
1034 BOOST_CONTAINER_FORCEINLINE multiset(std::initializer_list<value_type> il, const allocator_type& a)
1035 : base_t(false, il.begin(), il.end(), Compare(), a)
1038 //! @copydoc ::boost::container::set::set(std::initializer_list<value_type>, const Compare&)
1039 BOOST_CONTAINER_FORCEINLINE multiset(std::initializer_list<value_type> il, const Compare& comp)
1040 : base_t(false, il.begin(), il.end(), comp)
1043 //! @copydoc ::boost::container::set::set(std::initializer_list<value_type>, const Compare&, const allocator_type&)
1044 BOOST_CONTAINER_FORCEINLINE multiset(std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a)
1045 : base_t(false, il.begin(), il.end(), comp, a)
1048 //! @copydoc ::boost::container::set::set(ordered_unique_range_t, std::initializer_list<value_type>)
1049 BOOST_CONTAINER_FORCEINLINE multiset(ordered_range_t, std::initializer_list<value_type> il)
1050 : base_t(ordered_range, il.begin(), il.end())
1053 //! @copydoc ::boost::container::set::set(ordered_unique_range_t, std::initializer_list<value_type>, const Compare&)
1054 BOOST_CONTAINER_FORCEINLINE multiset(ordered_range_t, std::initializer_list<value_type> il, const Compare& comp)
1055 : base_t(ordered_range, il.begin(), il.end(), comp)
1058 //! @copydoc ::boost::container::set::set(ordered_unique_range_t, std::initializer_list<value_type>, const Compare&, const allocator_type&)
1059 BOOST_CONTAINER_FORCEINLINE multiset(ordered_range_t, std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a)
1060 : base_t(ordered_range, il.begin(), il.end(), comp, a)
1064 //! @copydoc ::boost::container::set::set(const set &)
1065 BOOST_CONTAINER_FORCEINLINE multiset(const multiset& x)
1066 : base_t(static_cast<const base_t&>(x))
1069 //! @copydoc ::boost::container::set::set(set &&)
1070 BOOST_CONTAINER_FORCEINLINE multiset(BOOST_RV_REF(multiset) x)
1071 BOOST_NOEXCEPT_IF(boost::container::dtl::is_nothrow_move_constructible<Compare>::value)
1072 : base_t(BOOST_MOVE_BASE(base_t, x))
1075 //! @copydoc ::boost::container::set::set(const set &, const allocator_type &)
1076 BOOST_CONTAINER_FORCEINLINE multiset(const multiset& x, const allocator_type &a)
1077 : base_t(static_cast<const base_t&>(x), a)
1080 //! @copydoc ::boost::container::set::set(set &&, const allocator_type &)
1081 BOOST_CONTAINER_FORCEINLINE multiset(BOOST_RV_REF(multiset) x, const allocator_type &a)
1082 : base_t(BOOST_MOVE_BASE(base_t, x), a)
1085 //! @copydoc ::boost::container::set::operator=(const set &)
1086 BOOST_CONTAINER_FORCEINLINE multiset& operator=(BOOST_COPY_ASSIGN_REF(multiset) x)
1087 { return static_cast<multiset&>(this->base_t::operator=(static_cast<const base_t&>(x))); }
1089 //! @copydoc ::boost::container::set::operator=(set &&)
1090 BOOST_CONTAINER_FORCEINLINE multiset& operator=(BOOST_RV_REF(multiset) x)
1091 BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value ||
1092 allocator_traits_type::is_always_equal::value) &&
1093 boost::container::dtl::is_nothrow_move_assignable<Compare>::value)
1094 { return static_cast<multiset&>(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); }
1096 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
1097 //! @copydoc ::boost::container::set::operator=(std::initializer_list<value_type>)
1098 multiset& operator=(std::initializer_list<value_type> il)
1101 insert(il.begin(), il.end());
1105 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
1107 //! @copydoc ::boost::container::set::get_allocator()
1108 allocator_type get_allocator() const;
1110 //! @copydoc ::boost::container::set::get_stored_allocator()
1111 stored_allocator_type &get_stored_allocator();
1113 //! @copydoc ::boost::container::set::get_stored_allocator() const
1114 const stored_allocator_type &get_stored_allocator() const;
1116 //! @copydoc ::boost::container::set::begin()
1119 //! @copydoc ::boost::container::set::begin() const
1120 const_iterator begin() const;
1122 //! @copydoc ::boost::container::set::cbegin() const
1123 const_iterator cbegin() const;
1125 //! @copydoc ::boost::container::set::end()
1126 iterator end() BOOST_NOEXCEPT_OR_NOTHROW;
1128 //! @copydoc ::boost::container::set::end() const
1129 const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW;
1131 //! @copydoc ::boost::container::set::cend() const
1132 const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW;
1134 //! @copydoc ::boost::container::set::rbegin()
1135 reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW;
1137 //! @copydoc ::boost::container::set::rbegin() const
1138 const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
1140 //! @copydoc ::boost::container::set::crbegin() const
1141 const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
1143 //! @copydoc ::boost::container::set::rend()
1144 reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW;
1146 //! @copydoc ::boost::container::set::rend() const
1147 const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW;
1149 //! @copydoc ::boost::container::set::crend() const
1150 const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW;
1152 //! @copydoc ::boost::container::set::empty() const
1155 //! @copydoc ::boost::container::set::size() const
1156 size_type size() const;
1158 //! @copydoc ::boost::container::set::max_size() const
1159 size_type max_size() const;
1161 #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
1163 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
1165 //! <b>Effects</b>: Inserts an object of type Key constructed with
1166 //! std::forward<Args>(args)... and returns the iterator pointing to the
1167 //! newly inserted element.
1169 //! <b>Complexity</b>: Logarithmic.
1170 template <class... Args>
1171 BOOST_CONTAINER_FORCEINLINE iterator emplace(BOOST_FWD_REF(Args)... args)
1172 { return this->base_t::emplace_equal(boost::forward<Args>(args)...); }
1174 //! <b>Effects</b>: Inserts an object of type Key constructed with
1175 //! std::forward<Args>(args)...
1177 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
1178 //! to the key of x.
1180 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
1181 //! is inserted right before p.
1182 template <class... Args>
1183 BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args)
1184 { return this->base_t::emplace_hint_equal(p, boost::forward<Args>(args)...); }
1186 #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
1188 #define BOOST_CONTAINER_MULTISET_EMPLACE_CODE(N) \
1189 BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
1190 BOOST_CONTAINER_FORCEINLINE iterator emplace(BOOST_MOVE_UREF##N)\
1191 { return this->base_t::emplace_equal(BOOST_MOVE_FWD##N); }\
1193 BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
1194 BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
1195 { return this->base_t::emplace_hint_equal(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\
1197 BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_MULTISET_EMPLACE_CODE)
1198 #undef BOOST_CONTAINER_MULTISET_EMPLACE_CODE
1200 #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
1202 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
1203 //! <b>Effects</b>: Inserts x and returns the iterator pointing to the
1204 //! newly inserted element.
1206 //! <b>Complexity</b>: Logarithmic.
1207 iterator insert(const value_type &x);
1209 //! <b>Effects</b>: Inserts a copy of x in the container.
1211 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
1212 //! to the key of x.
1214 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
1215 //! is inserted right before p.
1216 iterator insert(value_type &&x);
1218 BOOST_MOVE_CONVERSION_AWARE_CATCH(insert, value_type, iterator, this->priv_insert)
1221 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
1222 //! <b>Effects</b>: Inserts a copy of x in the container.
1223 //! p is a hint pointing to where the insert should start to search.
1225 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
1226 //! to the key of x.
1228 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
1229 //! is inserted right before p.
1230 iterator insert(const_iterator p, const value_type &x);
1232 //! <b>Effects</b>: Inserts a value move constructed from x in the container.
1233 //! p is a hint pointing to where the insert should start to search.
1235 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
1236 //! to the key of x.
1238 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
1239 //! is inserted right before p.
1240 iterator insert(const_iterator p, value_type &&x);
1242 BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, value_type, iterator, this->priv_insert, const_iterator, const_iterator)
1245 //! <b>Requires</b>: first, last are not iterators into *this.
1247 //! <b>Effects</b>: inserts each element from the range [first,last) .
1249 //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
1250 template <class InputIterator>
1251 BOOST_CONTAINER_FORCEINLINE void insert(InputIterator first, InputIterator last)
1252 { this->base_t::insert_equal(first, last); }
1254 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
1255 //! @copydoc ::boost::container::set::insert(std::initializer_list<value_type>)
1256 BOOST_CONTAINER_FORCEINLINE void insert(std::initializer_list<value_type> il)
1257 { this->base_t::insert_equal(il.begin(), il.end()); }
1260 //! @copydoc ::boost::container::multimap::insert(node_type&&)
1261 BOOST_CONTAINER_FORCEINLINE iterator insert(BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh)
1262 { return this->base_t::insert_equal_node(boost::move(nh)); }
1264 //! @copydoc ::boost::container::multimap::insert(const_iterator, node_type&&)
1265 BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator hint, BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh)
1266 { return this->base_t::insert_equal_node(hint, boost::move(nh)); }
1268 //! @copydoc ::boost::container::multimap::merge(multimap<Key, T, C2, Allocator, Options>&)
1270 BOOST_CONTAINER_FORCEINLINE void merge(multiset<Key, C2, Allocator, Options>& source)
1273 <Key, dtl::identity<Key>, C2, Allocator, Options> base2_t;
1274 this->base_t::merge_equal(static_cast<base2_t&>(source));
1277 //! @copydoc ::boost::container::multiset::merge(multiset<Key, C2, Allocator, Options>&)
1279 BOOST_CONTAINER_FORCEINLINE void merge(BOOST_RV_REF_BEG multiset<Key, C2, Allocator, Options> BOOST_RV_REF_END source)
1280 { return this->merge(static_cast<multiset<Key, C2, Allocator, Options>&>(source)); }
1282 //! @copydoc ::boost::container::multimap::merge(map<Key, T, C2, Allocator, Options>&)
1284 BOOST_CONTAINER_FORCEINLINE void merge(set<Key, C2, Allocator, Options>& source)
1287 <Key, dtl::identity<Key>, C2, Allocator, Options> base2_t;
1288 this->base_t::merge_equal(static_cast<base2_t&>(source));
1291 //! @copydoc ::boost::container::multiset::merge(set<Key, C2, Allocator, Options>&)
1293 BOOST_CONTAINER_FORCEINLINE void merge(BOOST_RV_REF_BEG set<Key, C2, Allocator, Options> BOOST_RV_REF_END source)
1294 { return this->merge(static_cast<set<Key, C2, Allocator, Options>&>(source)); }
1296 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
1298 //! @copydoc ::boost::container::set::erase(const_iterator)
1299 iterator erase(const_iterator p);
1301 //! @copydoc ::boost::container::set::erase(const key_type&)
1302 size_type erase(const key_type& x);
1304 //! @copydoc ::boost::container::set::erase(const_iterator,const_iterator)
1305 iterator erase(const_iterator first, const_iterator last);
1307 //! @copydoc ::boost::container::multimap::extract(const_iterator)
1308 node_type extract(const_iterator p);
1310 //! @copydoc ::boost::container::multimap::extract(const key_type&)
1311 node_type extract(const key_type& x);
1313 //! @copydoc ::boost::container::set::swap
1314 void swap(multiset& x)
1315 BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
1316 && boost::container::dtl::is_nothrow_swappable<Compare>::value );
1318 //! @copydoc ::boost::container::set::clear
1319 void clear() BOOST_NOEXCEPT_OR_NOTHROW;
1321 //! @copydoc ::boost::container::set::key_comp
1322 key_compare key_comp() const;
1324 //! @copydoc ::boost::container::set::value_comp
1325 value_compare value_comp() const;
1327 //! @copydoc ::boost::container::set::find(const key_type& )
1328 iterator find(const key_type& x);
1330 //! @copydoc ::boost::container::set::find(const key_type& ) const
1331 const_iterator find(const key_type& x) const;
1333 //! @copydoc ::boost::container::set::count(const key_type& ) const
1334 size_type count(const key_type& x) const;
1336 //! @copydoc ::boost::container::set::lower_bound(const key_type& )
1337 iterator lower_bound(const key_type& x);
1339 //! @copydoc ::boost::container::set::lower_bound(const key_type& ) const
1340 const_iterator lower_bound(const key_type& x) const;
1342 //! @copydoc ::boost::container::set::upper_bound(const key_type& )
1343 iterator upper_bound(const key_type& x);
1345 //! @copydoc ::boost::container::set::upper_bound(const key_type& ) const
1346 const_iterator upper_bound(const key_type& x) const;
1348 //! @copydoc ::boost::container::set::equal_range(const key_type& ) const
1349 std::pair<const_iterator, const_iterator> equal_range(const key_type& x) const;
1351 //! @copydoc ::boost::container::set::equal_range(const key_type& )
1352 std::pair<iterator,iterator> equal_range(const key_type& x);
1354 //! @copydoc ::boost::container::set::rebalance()
1357 //! <b>Effects</b>: Returns true if x and y are equal
1359 //! <b>Complexity</b>: Linear to the number of elements in the container.
1360 friend bool operator==(const multiset& x, const multiset& y);
1362 //! <b>Effects</b>: Returns true if x and y are unequal
1364 //! <b>Complexity</b>: Linear to the number of elements in the container.
1365 friend bool operator!=(const multiset& x, const multiset& y);
1367 //! <b>Effects</b>: Returns true if x is less than y
1369 //! <b>Complexity</b>: Linear to the number of elements in the container.
1370 friend bool operator<(const multiset& x, const multiset& y);
1372 //! <b>Effects</b>: Returns true if x is greater than y
1374 //! <b>Complexity</b>: Linear to the number of elements in the container.
1375 friend bool operator>(const multiset& x, const multiset& y);
1377 //! <b>Effects</b>: Returns true if x is equal or less than y
1379 //! <b>Complexity</b>: Linear to the number of elements in the container.
1380 friend bool operator<=(const multiset& x, const multiset& y);
1382 //! <b>Effects</b>: Returns true if x is equal or greater than y
1384 //! <b>Complexity</b>: Linear to the number of elements in the container.
1385 friend bool operator>=(const multiset& x, const multiset& y);
1387 //! <b>Effects</b>: x.swap(y)
1389 //! <b>Complexity</b>: Constant.
1390 friend void swap(multiset& x, multiset& y);
1392 #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
1394 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
1396 template <class KeyType>
1397 BOOST_CONTAINER_FORCEINLINE iterator priv_insert(BOOST_FWD_REF(KeyType) x)
1398 { return this->base_t::insert_equal(::boost::forward<KeyType>(x)); }
1400 template <class KeyType>
1401 BOOST_CONTAINER_FORCEINLINE iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x)
1402 { return this->base_t::insert_equal(p, ::boost::forward<KeyType>(x)); }
1404 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
1407 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
1409 } //namespace container {
1411 //!has_trivial_destructor_after_move<> == true_type
1412 //!specialization for optimizations
1413 template <class Key, class Compare, class Allocator, class Options>
1414 struct has_trivial_destructor_after_move<boost::container::multiset<Key, Compare, Allocator, Options> >
1416 typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
1417 static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
1418 ::boost::has_trivial_destructor_after_move<pointer>::value &&
1419 ::boost::has_trivial_destructor_after_move<Compare>::value;
1422 namespace container {
1424 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
1428 #include <boost/container/detail/config_end.hpp>
1430 #endif // BOOST_CONTAINER_SET_HPP