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