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