1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // See http://www.boost.org/libs/container for documentation.
9 //////////////////////////////////////////////////////////////////////////////
10 #ifndef BOOST_CONTAINER_FLAT_SET_HPP
11 #define BOOST_CONTAINER_FLAT_SET_HPP
13 #ifndef BOOST_CONFIG_HPP
14 # include <boost/config.hpp>
17 #if defined(BOOST_HAS_PRAGMA_ONCE)
21 #include <boost/container/detail/config_begin.hpp>
22 #include <boost/container/detail/workaround.hpp>
25 #include <boost/container/allocator_traits.hpp>
26 #include <boost/container/container_fwd.hpp>
27 #include <boost/container/new_allocator.hpp> //new_allocator
29 #include <boost/container/detail/flat_tree.hpp>
30 #include <boost/container/detail/mpl.hpp>
32 #include <boost/move/traits.hpp>
33 #include <boost/move/utility_core.hpp>
35 #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
36 #include <boost/move/detail/fwd_macros.hpp>
38 #include <boost/move/detail/move_helpers.hpp>
40 #include <boost/intrusive/detail/minimal_pair_header.hpp> //pair
41 #include <boost/intrusive/detail/minimal_less_equal_header.hpp>//less, equal
43 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
44 #include <initializer_list>
50 #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
51 template <class Key, class Compare, class AllocatorOrContainer>
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.
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>).
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.
67 //! This container provides random-access iterators.
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> >
79 template <class Key, class Compare, class AllocatorOrContainer>
83 : public container_detail::flat_tree<Key, container_detail::identity<Key>, Compare, AllocatorOrContainer>
86 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
88 BOOST_COPYABLE_AND_MOVABLE(flat_set)
89 typedef container_detail::flat_tree<Key, container_detail::identity<Key>, Compare, AllocatorOrContainer> tree_t;
95 const tree_t &tree() const
98 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
101 //////////////////////////////////////////////
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;
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;
127 //////////////////////////////////////////////
129 // construct/copy/destroy
131 //////////////////////////////////////////////
133 //! <b>Effects</b>: Default constructs an empty container.
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)
142 //! <b>Effects</b>: Constructs an empty container using the specified
143 //! comparison object.
145 //! <b>Complexity</b>: Constant.
146 BOOST_CONTAINER_FORCEINLINE
147 explicit flat_set(const Compare& comp)
151 //! <b>Effects</b>: Constructs an empty container using the specified allocator.
153 //! <b>Complexity</b>: Constant.
154 BOOST_CONTAINER_FORCEINLINE
155 explicit flat_set(const allocator_type& a)
159 //! <b>Effects</b>: Constructs an empty container using the specified
160 //! comparison object and allocator.
162 //! <b>Complexity</b>: Constant.
163 BOOST_CONTAINER_FORCEINLINE
164 flat_set(const Compare& comp, const allocator_type& a)
168 //! <b>Effects</b>: Constructs an empty container and
169 //! inserts elements from the range [first ,last ).
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)
179 //! <b>Effects</b>: Constructs an empty container using the specified
180 //! allocator, and inserts elements from the range [first ,last ).
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)
190 //! <b>Effects</b>: Constructs an empty container using the specified comparison object and
191 //! inserts elements from the range [first ,last ).
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)
201 //! <b>Effects</b>: Constructs an empty container using the specified comparison object and
202 //! allocator, and inserts elements from the range [first ,last ).
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)
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.
216 //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
219 //! <b>Complexity</b>: Linear in N.
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)
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.
232 //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
235 //! <b>Complexity</b>: Linear in N.
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)
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.
248 //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
251 //! <b>Complexity</b>: Linear in N.
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)
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()).
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())
270 //! <b>Effects</b>: Constructs an empty container using the specified
271 //! allocator, and inserts elements from the range [il.begin(), il.end()).
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)
279 //! <b>Effects</b>: Constructs an empty container using the specified comparison object and
280 //! inserts elements from the range [il.begin(), il.end()).
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)
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()).
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)
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.
301 //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be
304 //! <b>Complexity</b>: Linear in N.
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())
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.
315 //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be
318 //! <b>Complexity</b>: Linear in N.
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)
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.
329 //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be
332 //! <b>Complexity</b>: Linear in N.
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)
340 //! <b>Effects</b>: Copy constructs the container.
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))
347 //! <b>Effects</b>: Move constructs thecontainer. Constructs *this using x's resources.
349 //! <b>Complexity</b>: Constant.
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))
357 //! <b>Effects</b>: Copy constructs a container using the specified allocator.
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)
364 //! <b>Effects</b>: Move constructs a container using the specified allocator.
365 //! Constructs *this using x's resources.
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)
372 //! <b>Effects</b>: Makes *this a copy of x.
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))); }
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)
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))); }
390 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
391 //! <b>Effects</b>: Copy all elements from il to *this.
393 //! <b>Complexity</b>: Linear in il.size().
394 flat_set& operator=(std::initializer_list<value_type> il)
397 this->insert(il.begin(), il.end());
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.
406 //! <b>Complexity</b>: Constant.
407 allocator_type get_allocator() const BOOST_NOEXCEPT_OR_NOTHROW;
409 //! <b>Effects</b>: Returns a reference to the internal allocator.
411 //! <b>Throws</b>: Nothing
413 //! <b>Complexity</b>: Constant.
415 //! <b>Note</b>: Non-standard extension.
416 stored_allocator_type &get_stored_allocator() BOOST_NOEXCEPT_OR_NOTHROW;
418 //! <b>Effects</b>: Returns a reference to the internal allocator.
420 //! <b>Throws</b>: Nothing
422 //! <b>Complexity</b>: Constant.
424 //! <b>Note</b>: Non-standard extension.
425 const stored_allocator_type &get_stored_allocator() const BOOST_NOEXCEPT_OR_NOTHROW;
427 //! <b>Effects</b>: Returns an iterator to the first element contained in the container.
429 //! <b>Throws</b>: Nothing.
431 //! <b>Complexity</b>: Constant.
432 iterator begin() BOOST_NOEXCEPT_OR_NOTHROW;
434 //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
436 //! <b>Throws</b>: Nothing.
438 //! <b>Complexity</b>: Constant.
439 const_iterator begin() const BOOST_NOEXCEPT_OR_NOTHROW;
441 //! <b>Effects</b>: Returns an iterator to the end of the container.
443 //! <b>Throws</b>: Nothing.
445 //! <b>Complexity</b>: Constant.
446 iterator end() BOOST_NOEXCEPT_OR_NOTHROW;
448 //! <b>Effects</b>: Returns a const_iterator to the end of the container.
450 //! <b>Throws</b>: Nothing.
452 //! <b>Complexity</b>: Constant.
453 const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW;
455 //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
456 //! of the reversed container.
458 //! <b>Throws</b>: Nothing.
460 //! <b>Complexity</b>: Constant.
461 reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW;
463 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
464 //! of the reversed container.
466 //! <b>Throws</b>: Nothing.
468 //! <b>Complexity</b>: Constant.
469 const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
471 //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
472 //! of the reversed container.
474 //! <b>Throws</b>: Nothing.
476 //! <b>Complexity</b>: Constant.
477 reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW;
479 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
480 //! of the reversed container.
482 //! <b>Throws</b>: Nothing.
484 //! <b>Complexity</b>: Constant.
485 const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW;
487 //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
489 //! <b>Throws</b>: Nothing.
491 //! <b>Complexity</b>: Constant.
492 const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
494 //! <b>Effects</b>: Returns a const_iterator to the end of the container.
496 //! <b>Throws</b>: Nothing.
498 //! <b>Complexity</b>: Constant.
499 const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW;
501 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
502 //! of the reversed container.
504 //! <b>Throws</b>: Nothing.
506 //! <b>Complexity</b>: Constant.
507 const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
509 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
510 //! of the reversed container.
512 //! <b>Throws</b>: Nothing.
514 //! <b>Complexity</b>: Constant.
515 const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW;
517 //! <b>Effects</b>: Returns true if the container contains no elements.
519 //! <b>Throws</b>: Nothing.
521 //! <b>Complexity</b>: Constant.
522 bool empty() const BOOST_NOEXCEPT_OR_NOTHROW;
524 //! <b>Effects</b>: Returns the number of the elements contained in the container.
526 //! <b>Throws</b>: Nothing.
528 //! <b>Complexity</b>: Constant.
529 size_type size() const BOOST_NOEXCEPT_OR_NOTHROW;
531 //! <b>Effects</b>: Returns the largest possible size of the container.
533 //! <b>Throws</b>: Nothing.
535 //! <b>Complexity</b>: Constant.
536 size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW;
538 //! <b>Effects</b>: Number of elements for which memory has been allocated.
539 //! capacity() is always greater than or equal to size().
541 //! <b>Throws</b>: Nothing.
543 //! <b>Complexity</b>: Constant.
544 size_type capacity() const BOOST_NOEXCEPT_OR_NOTHROW;
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.
552 //! <b>Throws</b>: If memory allocation allocation throws or T's copy constructor throws.
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);
558 //! <b>Effects</b>: Tries to deallocate the excess of memory created
559 // with previous allocations. The size of the vector is unchanged
561 //! <b>Throws</b>: If memory allocation throws, or Key's copy constructor throws.
563 //! <b>Complexity</b>: Linear to size().
564 void shrink_to_fit();
566 #endif // #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
568 //////////////////////////////////////////////
572 //////////////////////////////////////////////
574 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
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.
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.
584 //! <b>Complexity</b>: Logarithmic search time plus linear insertion
585 //! to the elements with bigger keys than x.
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)...); }
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.
597 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
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.
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)...); }
608 #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
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); }\
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); }\
619 BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_FLAT_SET_EMPLACE_CODE)
620 #undef BOOST_CONTAINER_FLAT_SET_EMPLACE_CODE
622 #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
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.
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.
632 //! <b>Complexity</b>: Logarithmic search time plus linear insertion
633 //! to the elements with bigger keys than x.
635 //! <b>Note</b>: If an element is inserted it might invalidate elements.
636 std::pair<iterator, bool> insert(const value_type &x);
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.
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.
645 //! <b>Complexity</b>: Logarithmic search time plus linear insertion
646 //! to the elements with bigger keys than x.
648 //! <b>Note</b>: If an element is inserted it might invalidate elements.
649 std::pair<iterator, bool> insert(value_type &&x);
652 typedef std::pair<iterator, bool> insert_return_pair;
654 BOOST_MOVE_CONVERSION_AWARE_CATCH(insert, value_type, insert_return_pair, this->priv_insert)
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.
662 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
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.
668 //! <b>Note</b>: If an element is inserted it might invalidate elements.
669 iterator insert(const_iterator p, const value_type &x);
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.
674 //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x.
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.
679 //! <b>Note</b>: If an element is inserted it might invalidate elements.
680 iterator insert(const_iterator p, value_type &&x);
682 BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, value_type, iterator, this->priv_insert, const_iterator, const_iterator)
685 //! <b>Requires</b>: first, last are not iterators into *this.
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.
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.
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); }
698 //! <b>Requires</b>: first, last are not iterators into *this and
699 //! must be ordered according to the predicate and must be
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.
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.
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); }
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.
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.
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()); }
724 //! <b>Requires</b>: Range [il.begin(), il.end()) must be ordered according to the predicate
725 //! and must be unique values.
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.
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.
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()); }
738 //! @copydoc ::boost::container::flat_map::merge(flat_map<Key, T, C2, AllocatorOrContainer>&)
740 BOOST_CONTAINER_FORCEINLINE void merge(flat_set<Key, C2, AllocatorOrContainer>& source)
741 { this->tree_t::merge_unique(source.tree()); }
743 //! @copydoc ::boost::container::flat_set::merge(flat_set<Key, C2, AllocatorOrContainer>&)
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)); }
748 //! @copydoc ::boost::container::flat_map::merge(flat_multimap<Key, T, C2, AllocatorOrContainer>&)
750 BOOST_CONTAINER_FORCEINLINE void merge(flat_multiset<Key, C2, AllocatorOrContainer>& source)
751 { this->tree_t::merge_unique(source.tree()); }
753 //! @copydoc ::boost::container::flat_set::merge(flat_multiset<Key, C2, AllocatorOrContainer>&)
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)); }
758 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
760 //! <b>Effects</b>: Erases the element pointed to by p.
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,
766 //! <b>Complexity</b>: Linear to the elements with keys bigger than p
768 //! <b>Note</b>: Invalidates elements with keys
769 //! not less than the erased element.
770 iterator erase(const_iterator p);
772 //! <b>Effects</b>: Erases all elements in the container with key equivalent to x.
774 //! <b>Returns</b>: Returns the number of erased elements.
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);
780 //! <b>Effects</b>: Erases all the elements in the range [first, last).
782 //! <b>Returns</b>: Returns last.
784 //! <b>Complexity</b>: size()*N where N is the distance from first to last.
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);
790 //! <b>Effects</b>: Swaps the contents of *this and x.
792 //! <b>Throws</b>: Nothing.
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 );
799 //! <b>Effects</b>: erase(a.begin(),a.end()).
801 //! <b>Postcondition</b>: size() == 0.
803 //! <b>Complexity</b>: linear in size().
804 void clear() BOOST_NOEXCEPT_OR_NOTHROW;
806 //! <b>Effects</b>: Returns the comparison object out
807 //! of which a was constructed.
809 //! <b>Complexity</b>: Constant.
810 key_compare key_comp() const;
812 //! <b>Effects</b>: Returns an object of value_compare constructed out
813 //! of the comparison object.
815 //! <b>Complexity</b>: Constant.
816 value_compare value_comp() const;
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.
821 //! <b>Complexity</b>: Logarithmic.
822 iterator find(const key_type& x);
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.
827 //! <b>Complexity</b>: Logarithmic.
828 const_iterator find(const key_type& x) const;
830 //! <b>Requires</b>: size() >= n.
832 //! <b>Effects</b>: Returns an iterator to the nth element
833 //! from the beginning of the container. Returns end()
836 //! <b>Throws</b>: Nothing.
838 //! <b>Complexity</b>: Constant.
840 //! <b>Note</b>: Non-standard extension
841 iterator nth(size_type n) BOOST_NOEXCEPT_OR_NOTHROW;
843 //! <b>Requires</b>: size() >= n.
845 //! <b>Effects</b>: Returns a const_iterator to the nth element
846 //! from the beginning of the container. Returns end()
849 //! <b>Throws</b>: Nothing.
851 //! <b>Complexity</b>: Constant.
853 //! <b>Note</b>: Non-standard extension
854 const_iterator nth(size_type n) const BOOST_NOEXCEPT_OR_NOTHROW;
856 //! <b>Requires</b>: begin() <= p <= end().
858 //! <b>Effects</b>: Returns the index of the element pointed by p
859 //! and size() if p == end().
861 //! <b>Throws</b>: Nothing.
863 //! <b>Complexity</b>: Constant.
865 //! <b>Note</b>: Non-standard extension
866 size_type index_of(iterator p) BOOST_NOEXCEPT_OR_NOTHROW;
868 //! <b>Requires</b>: begin() <= p <= end().
870 //! <b>Effects</b>: Returns the index of the element pointed by p
871 //! and size() if p == end().
873 //! <b>Throws</b>: Nothing.
875 //! <b>Complexity</b>: Constant.
877 //! <b>Note</b>: Non-standard extension
878 size_type index_of(const_iterator p) const BOOST_NOEXCEPT_OR_NOTHROW;
880 #endif // #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
882 //! <b>Returns</b>: The number of elements with key equivalent to x.
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()); }
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.
892 //! <b>Complexity</b>: Logarithmic
893 iterator lower_bound(const key_type& x);
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.
898 //! <b>Complexity</b>: Logarithmic
899 const_iterator lower_bound(const key_type& x) const;
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.
904 //! <b>Complexity</b>: Logarithmic
905 iterator upper_bound(const key_type& x);
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.
910 //! <b>Complexity</b>: Logarithmic
911 const_iterator upper_bound(const key_type& x) const;
913 #endif // #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
915 //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
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); }
921 //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
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); }
927 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
929 //! <b>Effects</b>: Returns true if x and y are equal
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);
934 //! <b>Effects</b>: Returns true if x and y are unequal
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);
939 //! <b>Effects</b>: Returns true if x is less than y
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);
944 //! <b>Effects</b>: Returns true if x is greater than y
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);
949 //! <b>Effects</b>: Returns true if x is equal or less than y
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);
954 //! <b>Effects</b>: Returns true if x is equal or greater than y
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);
959 //! <b>Effects</b>: x.swap(y)
961 //! <b>Complexity</b>: Constant.
962 friend void swap(flat_set& x, flat_set& y);
964 //! <b>Effects</b>: Extracts the internal sequence container.
966 //! <b>Complexity</b>: Same as the move constructor of sequence_type, usually constant.
968 //! <b>Postcondition</b>: this->empty()
970 //! <b>Throws</b>: If secuence_type's move constructor throws
971 sequence_type extract_sequence();
973 #endif //#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
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.
978 //! <b>Complexity</b>: Assuming O(1) move assignment, O(NlogN) with N = seq.size()
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)); }
984 //! <b>Requires</b>: seq shall be ordered according to this->compare()
985 //! and shall contain unique elements.
987 //! <b>Effects</b>: Discards the internally hold sequence container and adopts the
988 //! one passed externally using the move assignment.
990 //! <b>Complexity</b>: Assuming O(1) move assignment, O(1)
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)); }
996 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
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)); }
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
1008 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
1010 } //namespace container {
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> >
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;
1023 namespace container {
1025 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
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.
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>).
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.
1039 //! This container provides random-access iterators.
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> >
1051 template <class Key, class Compare, class AllocatorOrContainer>
1055 : public container_detail::flat_tree<Key, container_detail::identity<Key>, Compare, AllocatorOrContainer>
1058 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
1060 BOOST_COPYABLE_AND_MOVABLE(flat_multiset)
1061 typedef container_detail::flat_tree<Key, container_detail::identity<Key>, Compare, AllocatorOrContainer> tree_t;
1067 const tree_t &tree() const
1069 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
1072 //////////////////////////////////////////////
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;
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;
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)
1103 //! @copydoc ::boost::container::flat_set::flat_set(const Compare&)
1104 BOOST_CONTAINER_FORCEINLINE explicit flat_multiset(const Compare& comp)
1108 //! @copydoc ::boost::container::flat_set::flat_set(const allocator_type&)
1109 BOOST_CONTAINER_FORCEINLINE explicit flat_multiset(const allocator_type& a)
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)
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)
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)
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)
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)
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.
1146 //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
1148 //! <b>Complexity</b>: Linear in N.
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)
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.
1160 //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
1162 //! <b>Complexity</b>: Linear in N.
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)
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.
1174 //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
1176 //! <b>Complexity</b>: Linear in N.
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)
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())
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)
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)
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)
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.
1209 //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate.
1211 //! <b>Complexity</b>: Linear in N.
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())
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.
1222 //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate.
1224 //! <b>Complexity</b>: Linear in N.
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)
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.
1235 //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate.
1237 //! <b>Complexity</b>: Linear in N.
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)
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))
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)))
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)
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)
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))); }
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))); }
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)
1282 this->insert(il.begin(), il.end());
1287 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
1289 //! @copydoc ::boost::container::flat_set::get_allocator()
1290 allocator_type get_allocator() const BOOST_NOEXCEPT_OR_NOTHROW;
1292 //! @copydoc ::boost::container::flat_set::get_stored_allocator()
1293 stored_allocator_type &get_stored_allocator() BOOST_NOEXCEPT_OR_NOTHROW;
1295 //! @copydoc ::boost::container::flat_set::get_stored_allocator() const
1296 const stored_allocator_type &get_stored_allocator() const BOOST_NOEXCEPT_OR_NOTHROW;
1298 //! @copydoc ::boost::container::flat_set::begin()
1299 iterator begin() BOOST_NOEXCEPT_OR_NOTHROW;
1301 //! @copydoc ::boost::container::flat_set::begin() const
1302 const_iterator begin() const;
1304 //! @copydoc ::boost::container::flat_set::cbegin() const
1305 const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
1307 //! @copydoc ::boost::container::flat_set::end()
1308 iterator end() BOOST_NOEXCEPT_OR_NOTHROW;
1310 //! @copydoc ::boost::container::flat_set::end() const
1311 const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW;
1313 //! @copydoc ::boost::container::flat_set::cend() const
1314 const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW;
1316 //! @copydoc ::boost::container::flat_set::rbegin()
1317 reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW;
1319 //! @copydoc ::boost::container::flat_set::rbegin() const
1320 const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
1322 //! @copydoc ::boost::container::flat_set::crbegin() const
1323 const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
1325 //! @copydoc ::boost::container::flat_set::rend()
1326 reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW;
1328 //! @copydoc ::boost::container::flat_set::rend() const
1329 const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW;
1331 //! @copydoc ::boost::container::flat_set::crend() const
1332 const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW;
1334 //! @copydoc ::boost::container::flat_set::empty() const
1335 bool empty() const BOOST_NOEXCEPT_OR_NOTHROW;
1337 //! @copydoc ::boost::container::flat_set::size() const
1338 size_type size() const BOOST_NOEXCEPT_OR_NOTHROW;
1340 //! @copydoc ::boost::container::flat_set::max_size() const
1341 size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW;
1343 //! @copydoc ::boost::container::flat_set::capacity() const
1344 size_type capacity() const BOOST_NOEXCEPT_OR_NOTHROW;
1346 //! @copydoc ::boost::container::flat_set::reserve(size_type)
1347 void reserve(size_type cnt);
1349 //! @copydoc ::boost::container::flat_set::shrink_to_fit()
1350 void shrink_to_fit();
1352 #endif // #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
1354 //////////////////////////////////////////////
1358 //////////////////////////////////////////////
1360 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
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.
1366 //! <b>Complexity</b>: Logarithmic search time plus linear insertion
1367 //! to the elements with bigger keys than x.
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)...); }
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.
1378 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
1379 //! to the key of x.
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.
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)...); }
1389 #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
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); }\
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); }\
1400 BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_FLAT_MULTISET_EMPLACE_CODE)
1401 #undef BOOST_CONTAINER_FLAT_MULTISET_EMPLACE_CODE
1403 #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
1405 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
1406 //! <b>Effects</b>: Inserts x and returns the iterator pointing to the
1407 //! newly inserted element.
1409 //! <b>Complexity</b>: Logarithmic search time plus linear insertion
1410 //! to the elements with bigger keys than x.
1412 //! <b>Note</b>: If an element is inserted it might invalidate elements.
1413 iterator insert(const value_type &x);
1415 //! <b>Effects</b>: Inserts a new value_type move constructed from x
1416 //! and returns the iterator pointing to the newly inserted element.
1418 //! <b>Complexity</b>: Logarithmic search time plus linear insertion
1419 //! to the elements with bigger keys than x.
1421 //! <b>Note</b>: If an element is inserted it might invalidate elements.
1422 iterator insert(value_type &&x);
1424 BOOST_MOVE_CONVERSION_AWARE_CATCH(insert, value_type, iterator, this->priv_insert)
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.
1431 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
1432 //! to the key of x.
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.
1437 //! <b>Note</b>: If an element is inserted it might invalidate elements.
1438 iterator insert(const_iterator p, const value_type &x);
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.
1443 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
1444 //! to the key of x.
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.
1449 //! <b>Note</b>: If an element is inserted it might invalidate elements.
1450 iterator insert(const_iterator p, value_type &&x);
1452 BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, value_type, iterator, this->priv_insert, const_iterator, const_iterator)
1455 //! <b>Requires</b>: first, last are not iterators into *this.
1457 //! <b>Effects</b>: inserts each element from the range [first,last) .
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.
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); }
1467 //! <b>Requires</b>: first, last are not iterators into *this and
1468 //! must be ordered according to the predicate.
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.
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.
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); }
1481 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
1482 //! <b>Effects</b>: inserts each element from the range [il.begin(), il.end()).
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.
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()); }
1491 //! <b>Requires</b>: Range [il.begin(), il.end()) must be ordered according to the predicate.
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.
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.
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()); }
1504 //! @copydoc ::boost::container::flat_multimap::merge(flat_multimap<Key, T, C2, AllocatorOrContainer>&)
1506 BOOST_CONTAINER_FORCEINLINE void merge(flat_multiset<Key, C2, AllocatorOrContainer>& source)
1507 { this->tree_t::merge_equal(source.tree()); }
1509 //! @copydoc ::boost::container::flat_multiset::merge(flat_multiset<Key, C2, AllocatorOrContainer>&)
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)); }
1514 //! @copydoc ::boost::container::flat_multimap::merge(flat_map<Key, T, C2, AllocatorOrContainer>&)
1516 BOOST_CONTAINER_FORCEINLINE void merge(flat_set<Key, C2, AllocatorOrContainer>& source)
1517 { this->tree_t::merge_equal(source.tree()); }
1519 //! @copydoc ::boost::container::flat_multiset::merge(flat_set<Key, C2, AllocatorOrContainer>&)
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)); }
1524 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
1526 //! @copydoc ::boost::container::flat_set::erase(const_iterator)
1527 iterator erase(const_iterator p);
1529 //! @copydoc ::boost::container::flat_set::erase(const key_type&)
1530 size_type erase(const key_type& x);
1532 //! @copydoc ::boost::container::flat_set::erase(const_iterator,const_iterator)
1533 iterator erase(const_iterator first, const_iterator last);
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 );
1540 //! @copydoc ::boost::container::flat_set::clear
1541 void clear() BOOST_NOEXCEPT_OR_NOTHROW;
1543 //! @copydoc ::boost::container::flat_set::key_comp
1544 key_compare key_comp() const;
1546 //! @copydoc ::boost::container::flat_set::value_comp
1547 value_compare value_comp() const;
1549 //! @copydoc ::boost::container::flat_set::find(const key_type& )
1550 iterator find(const key_type& x);
1552 //! @copydoc ::boost::container::flat_set::find(const key_type& ) const
1553 const_iterator find(const key_type& x) const;
1555 //! @copydoc ::boost::container::flat_set::nth(size_type)
1556 iterator nth(size_type n) BOOST_NOEXCEPT_OR_NOTHROW;
1558 //! @copydoc ::boost::container::flat_set::nth(size_type) const
1559 const_iterator nth(size_type n) const BOOST_NOEXCEPT_OR_NOTHROW;
1561 //! @copydoc ::boost::container::flat_set::index_of(iterator)
1562 size_type index_of(iterator p) BOOST_NOEXCEPT_OR_NOTHROW;
1564 //! @copydoc ::boost::container::flat_set::index_of(const_iterator) const
1565 size_type index_of(const_iterator p) const BOOST_NOEXCEPT_OR_NOTHROW;
1567 //! @copydoc ::boost::container::flat_set::count(const key_type& ) const
1568 size_type count(const key_type& x) const;
1570 //! @copydoc ::boost::container::flat_set::lower_bound(const key_type& )
1571 iterator lower_bound(const key_type& x);
1573 //! @copydoc ::boost::container::flat_set::lower_bound(const key_type& ) const
1574 const_iterator lower_bound(const key_type& x) const;
1576 //! @copydoc ::boost::container::flat_set::upper_bound(const key_type& )
1577 iterator upper_bound(const key_type& x);
1579 //! @copydoc ::boost::container::flat_set::upper_bound(const key_type& ) const
1580 const_iterator upper_bound(const key_type& x) const;
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;
1585 //! @copydoc ::boost::container::flat_set::equal_range(const key_type& )
1586 std::pair<iterator,iterator> equal_range(const key_type& x);
1588 //! <b>Effects</b>: Returns true if x and y are equal
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);
1593 //! <b>Effects</b>: Returns true if x and y are unequal
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);
1598 //! <b>Effects</b>: Returns true if x is less than y
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);
1603 //! <b>Effects</b>: Returns true if x is greater than y
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);
1608 //! <b>Effects</b>: Returns true if x is equal or less than y
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);
1613 //! <b>Effects</b>: Returns true if x is equal or greater than y
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);
1618 //! <b>Effects</b>: x.swap(y)
1620 //! <b>Complexity</b>: Constant.
1621 friend void swap(flat_multiset& x, flat_multiset& y);
1623 //! <b>Effects</b>: Extracts the internal sequence container.
1625 //! <b>Complexity</b>: Same as the move constructor of sequence_type, usually constant.
1627 //! <b>Postcondition</b>: this->empty()
1629 //! <b>Throws</b>: If secuence_type's move constructor throws
1630 sequence_type extract_sequence();
1632 #endif //#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
1634 //! <b>Effects</b>: Discards the internally hold sequence container and adopts the
1635 //! one passed externally using the move assignment.
1637 //! <b>Complexity</b>: Assuming O(1) move assignment, O(NlogN) with N = seq.size()
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)); }
1643 //! <b>Requires</b>: seq shall be ordered according to this->compare()
1645 //! <b>Effects</b>: Discards the internally hold sequence container and adopts the
1646 //! one passed externally using the move assignment.
1648 //! <b>Complexity</b>: Assuming O(1) move assignment, O(1)
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)); }
1654 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
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)); }
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
1666 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
1668 } //namespace container {
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> >
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;
1681 namespace container {
1683 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
1687 #include <boost/container/detail/config_end.hpp>
1689 #endif // BOOST_CONTAINER_FLAT_SET_HPP