56#ifndef _STL_MULTISET_H
57#define _STL_MULTISET_H 1
60#if __cplusplus >= 201103L
64namespace std _GLIBCXX_VISIBILITY(default)
66_GLIBCXX_BEGIN_NAMESPACE_VERSION
67_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
69 template<
typename _Key,
typename _Compare,
typename _Alloc>
94 template <
typename _Key,
typename _Compare = std::less<_Key>,
95 typename _Alloc = std::allocator<_Key> >
98#ifdef _GLIBCXX_CONCEPT_CHECKS
100 typedef typename _Alloc::value_type _Alloc_value_type;
101# if __cplusplus < 201103L
102 __glibcxx_class_requires(_Key, _SGIAssignableConcept)
104 __glibcxx_class_requires4(_Compare,
bool, _Key, _Key,
105 _BinaryFunctionConcept)
106 __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
109#if __cplusplus >= 201103L
111 "std::multiset must have a non-const, non-volatile value_type");
112# if __cplusplus > 201703L || defined __STRICT_ANSI__
114 "std::multiset must have the same value_type as its allocator");
120 typedef _Key key_type;
121 typedef _Key value_type;
122 typedef _Compare key_compare;
123 typedef _Compare value_compare;
124 typedef _Alloc allocator_type;
129 rebind<_Key>::other _Key_alloc_type;
131 typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
132 key_compare, _Key_alloc_type> _Rep_type;
139 typedef typename _Alloc_traits::pointer pointer;
140 typedef typename _Alloc_traits::const_pointer const_pointer;
141 typedef typename _Alloc_traits::reference reference;
142 typedef typename _Alloc_traits::const_reference const_reference;
146 typedef typename _Rep_type::const_iterator iterator;
147 typedef typename _Rep_type::const_iterator const_iterator;
150 typedef typename _Rep_type::size_type size_type;
151 typedef typename _Rep_type::difference_type difference_type;
153#if __cplusplus > 201402L
161#if __cplusplus < 201103L
174 const allocator_type& __a = allocator_type())
175 : _M_t(__comp, _Key_alloc_type(__a)) { }
186 template<
typename _InputIterator>
187 multiset(_InputIterator __first, _InputIterator __last)
189 { _M_t._M_insert_range_equal(__first, __last); }
202 template<
typename _InputIterator>
203 multiset(_InputIterator __first, _InputIterator __last,
204 const _Compare& __comp,
205 const allocator_type& __a = allocator_type())
206 : _M_t(__comp, _Key_alloc_type(__a))
207 { _M_t._M_insert_range_equal(__first, __last); }
214#if __cplusplus < 201103L
240 const _Compare& __comp = _Compare(),
241 const allocator_type& __a = allocator_type())
242 : _M_t(__comp, _Key_alloc_type(__a))
243 { _M_t._M_insert_range_equal(__l.begin(), __l.end()); }
248 : _M_t(_Key_alloc_type(__a)) { }
252 : _M_t(__m._M_t, _Key_alloc_type(__a)) { }
257 && _Alloc_traits::_S_always_equal())
258 : _M_t(
std::
move(__m._M_t), _Key_alloc_type(__a)) { }
262 : _M_t(_Key_alloc_type(__a))
263 { _M_t._M_insert_range_equal(__l.begin(), __l.end()); }
266 template<
typename _InputIterator>
267 multiset(_InputIterator __first, _InputIterator __last,
268 const allocator_type& __a)
269 : _M_t(_Key_alloc_type(__a))
270 { _M_t._M_insert_range_equal(__first, __last); }
285#if __cplusplus < 201103L
314 _M_t._M_assign_equal(__l.begin(), __l.end());
324 {
return _M_t.key_comp(); }
328 {
return _M_t.key_comp(); }
332 {
return allocator_type(_M_t.get_allocator()); }
341 {
return _M_t.begin(); }
349 end() const _GLIBCXX_NOEXCEPT
350 {
return _M_t.end(); }
359 {
return _M_t.rbegin(); }
368 {
return _M_t.rend(); }
370#if __cplusplus >= 201103L
378 {
return _M_t.begin(); }
387 {
return _M_t.end(); }
396 {
return _M_t.rbegin(); }
405 {
return _M_t.rend(); }
409 _GLIBCXX_NODISCARD
bool
411 {
return _M_t.empty(); }
416 {
return _M_t.size(); }
421 {
return _M_t.max_size(); }
438 _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
439 { _M_t.swap(__x._M_t); }
442#if __cplusplus >= 201103L
455 template<
typename... _Args>
458 {
return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); }
481 template<
typename... _Args>
485 return _M_t._M_emplace_hint_equal(__pos,
486 std::forward<_Args>(__args)...);
503 {
return _M_t._M_insert_equal(__x); }
505#if __cplusplus >= 201103L
508 {
return _M_t._M_insert_equal(
std::move(__x)); }
532 insert(const_iterator __position,
const value_type& __x)
533 {
return _M_t._M_insert_equal_(__position, __x); }
535#if __cplusplus >= 201103L
537 insert(const_iterator __position, value_type&& __x)
538 {
return _M_t._M_insert_equal_(__position,
std::move(__x)); }
549 template<
typename _InputIterator>
551 insert(_InputIterator __first, _InputIterator __last)
552 { _M_t._M_insert_range_equal(__first, __last); }
554#if __cplusplus >= 201103L
564 { this->
insert(__l.begin(), __l.end()); }
567#if __cplusplus > 201402L
572 __glibcxx_assert(__pos !=
end());
573 return _M_t.extract(__pos);
579 {
return _M_t.extract(__x); }
584 {
return _M_t._M_reinsert_node_equal(
std::move(__nh)); }
588 insert(const_iterator __hint, node_type&& __nh)
589 {
return _M_t._M_reinsert_node_hint_equal(__hint,
std::move(__nh)); }
591 template<
typename,
typename>
592 friend struct std::_Rb_tree_merge_helper;
594 template<
typename _Compare1>
598 using _Merge_helper = _Rb_tree_merge_helper<multiset, _Compare1>;
599 _M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source));
602 template<
typename _Compare1>
604 merge(multiset<_Key, _Compare1, _Alloc>&& __source)
607 template<
typename _Compare1>
609 merge(set<_Key, _Compare1, _Alloc>& __source)
611 using _Merge_helper = _Rb_tree_merge_helper<multiset, _Compare1>;
612 _M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source));
615 template<
typename _Compare1>
617 merge(set<_Key, _Compare1, _Alloc>&& __source)
621#if __cplusplus >= 201103L
637 _GLIBCXX_ABI_TAG_CXX11
640 {
return _M_t.erase(__position); }
654 { _M_t.erase(__position); }
670 {
return _M_t.erase(__x); }
672#if __cplusplus >= 201103L
689 _GLIBCXX_ABI_TAG_CXX11
691 erase(const_iterator __first, const_iterator __last)
692 {
return _M_t.erase(__first, __last); }
708 { _M_t.erase(__first, __last); }
731 {
return _M_t.count(__x); }
733#if __cplusplus > 201103L
734 template<
typename _Kt>
736 count(
const _Kt& __x)
const ->
decltype(_M_t._M_count_tr(__x))
737 {
return _M_t._M_count_tr(__x); }
741#if __cplusplus > 201703L
749 contains(
const key_type& __x)
const
750 {
return _M_t.find(__x) != _M_t.end(); }
752 template<
typename _Kt>
754 contains(
const _Kt& __x)
const
755 ->
decltype(_M_t._M_find_tr(__x), void(),
true)
756 {
return _M_t._M_find_tr(__x) != _M_t.end(); }
776 {
return _M_t.find(__x); }
779 find(
const key_type& __x)
const
780 {
return _M_t.find(__x); }
782#if __cplusplus > 201103L
783 template<
typename _Kt>
786 ->
decltype(iterator{_M_t._M_find_tr(__x)})
787 {
return iterator{_M_t._M_find_tr(__x)}; }
789 template<
typename _Kt>
792 ->
decltype(const_iterator{_M_t._M_find_tr(__x)})
793 {
return const_iterator{_M_t._M_find_tr(__x)}; }
811 {
return _M_t.lower_bound(__x); }
815 {
return _M_t.lower_bound(__x); }
817#if __cplusplus > 201103L
818 template<
typename _Kt>
821 ->
decltype(iterator(_M_t._M_lower_bound_tr(__x)))
822 {
return iterator(_M_t._M_lower_bound_tr(__x)); }
824 template<
typename _Kt>
827 ->
decltype(iterator(_M_t._M_lower_bound_tr(__x)))
828 {
return iterator(_M_t._M_lower_bound_tr(__x)); }
841 {
return _M_t.upper_bound(__x); }
845 {
return _M_t.upper_bound(__x); }
847#if __cplusplus > 201103L
848 template<
typename _Kt>
851 ->
decltype(iterator(_M_t._M_upper_bound_tr(__x)))
852 {
return iterator(_M_t._M_upper_bound_tr(__x)); }
854 template<
typename _Kt>
857 ->
decltype(iterator(_M_t._M_upper_bound_tr(__x)))
858 {
return iterator(_M_t._M_upper_bound_tr(__x)); }
880 {
return _M_t.equal_range(__x); }
884 {
return _M_t.equal_range(__x); }
886#if __cplusplus > 201103L
887 template<
typename _Kt>
893 template<
typename _Kt>
901 template<
typename _K1,
typename _C1,
typename _A1>
906#if __cpp_lib_three_way_comparison
907 template<
typename _K1,
typename _C1,
typename _A1>
908 friend __detail::__synth3way_t<_K1>
912 template<
typename _K1,
typename _C1,
typename _A1>
919#if __cpp_deduction_guides >= 201606
921 template<
typename _InputIterator,
923 less<typename iterator_traits<_InputIterator>::value_type>,
924 typename _Allocator =
925 allocator<typename iterator_traits<_InputIterator>::value_type>,
926 typename = _RequireInputIter<_InputIterator>,
927 typename = _RequireNotAllocator<_Compare>,
928 typename = _RequireAllocator<_Allocator>>
929 multiset(_InputIterator, _InputIterator,
930 _Compare = _Compare(), _Allocator = _Allocator())
931 -> multiset<typename iterator_traits<_InputIterator>::value_type,
932 _Compare, _Allocator>;
934 template<
typename _Key,
935 typename _Compare = less<_Key>,
936 typename _Allocator = allocator<_Key>,
937 typename = _RequireNotAllocator<_Compare>,
938 typename = _RequireAllocator<_Allocator>>
939 multiset(initializer_list<_Key>,
940 _Compare = _Compare(), _Allocator = _Allocator())
941 -> multiset<_Key, _Compare, _Allocator>;
943 template<
typename _InputIterator,
typename _Allocator,
944 typename = _RequireInputIter<_InputIterator>,
945 typename = _RequireAllocator<_Allocator>>
946 multiset(_InputIterator, _InputIterator, _Allocator)
947 -> multiset<typename iterator_traits<_InputIterator>::value_type,
948 less<typename iterator_traits<_InputIterator>::value_type>,
951 template<
typename _Key,
typename _Allocator,
952 typename = _RequireAllocator<_Allocator>>
953 multiset(initializer_list<_Key>, _Allocator)
954 -> multiset<_Key, less<_Key>, _Allocator>;
969 template<
typename _Key,
typename _Compare,
typename _Alloc>
973 {
return __x._M_t == __y._M_t; }
975#if __cpp_lib_three_way_comparison
990 template<
typename _Key,
typename _Compare,
typename _Alloc>
991 inline __detail::__synth3way_t<_Key>
992 operator<=>(
const multiset<_Key, _Compare, _Alloc>& __x,
993 const multiset<_Key, _Compare, _Alloc>& __y)
994 {
return __x._M_t <=> __y._M_t; }
1007 template<
typename _Key,
typename _Compare,
typename _Alloc>
1011 {
return __x._M_t < __y._M_t; }
1014 template<
typename _Key,
typename _Compare,
typename _Alloc>
1018 {
return !(__x == __y); }
1021 template<
typename _Key,
typename _Compare,
typename _Alloc>
1025 {
return __y < __x; }
1028 template<
typename _Key,
typename _Compare,
typename _Alloc>
1032 {
return !(__y < __x); }
1035 template<
typename _Key,
typename _Compare,
typename _Alloc>
1039 {
return !(__x < __y); }
1043 template<
typename _Key,
typename _Compare,
typename _Alloc>
1047 _GLIBCXX_NOEXCEPT_IF(
noexcept(__x.swap(__y)))
1050_GLIBCXX_END_NAMESPACE_CONTAINER
1052#if __cplusplus > 201402L
1054 template<
typename _Val,
typename _Cmp1,
typename _Alloc,
typename _Cmp2>
1056 _Rb_tree_merge_helper<_GLIBCXX_STD_C::multiset<_Val, _Cmp1, _Alloc>,
1060 friend class _GLIBCXX_STD_C::multiset<_Val, _Cmp1, _Alloc>;
1063 _S_get_tree(_GLIBCXX_STD_C::set<_Val, _Cmp2, _Alloc>& __set)
1064 {
return __set._M_t; }
1067 _S_get_tree(_GLIBCXX_STD_C::multiset<_Val, _Cmp2, _Alloc>& __set)
1068 {
return __set._M_t; }
1072_GLIBCXX_END_NAMESPACE_VERSION
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
ISO C++ entities toplevel namespace is std.
is_nothrow_copy_constructible
Node handle type for maps.
A standard container made up of elements, which can be retrieved in logarithmic time.
multiset(multiset &&__m, const allocator_type &__a) noexcept(is_nothrow_copy_constructible< _Compare >::value &&_Alloc_traits::_S_always_equal())
Allocator-extended move constructor.
iterator emplace(_Args &&... __args)
Builds and inserts an element into the multiset.
multiset(_InputIterator __first, _InputIterator __last, const allocator_type &__a)
Allocator-extended range constructor.
iterator emplace_hint(const_iterator __pos, _Args &&... __args)
Builds and inserts an element into the multiset.
reverse_iterator crend() const noexcept
auto find(const _Kt &__x) const -> decltype(const_iterator{_M_t._M_find_tr(__x)})
Tries to locate an element in a set.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
multiset & operator=(const multiset &)=default
Multiset assignment operator.
iterator insert(node_type &&__nh)
Re-insert an extracted node.
_GLIBCXX_ABI_TAG_CXX11 iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a multiset.
reverse_iterator crbegin() const noexcept
multiset(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a multiset with no elements.
multiset(const multiset &__m, const allocator_type &__a)
Allocator-extended copy constructor.
auto count(const _Kt &__x) const -> decltype(_M_t._M_count_tr(__x))
Finds the number of elements with given key.
void swap(multiset &__x) noexcept(/*conditional */)
Swaps data with another multiset.
iterator cbegin() const noexcept
value_compare value_comp() const
Returns the comparison object.
multiset(initializer_list< value_type > __l, const allocator_type &__a)
Allocator-extended initialier-list constructor.
auto upper_bound(const _Kt &__x) const -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
Finds the end of a subsequence matching given key.
bool empty() const noexcept
Returns true if the set is empty.
node_type extract(const_iterator __pos)
Extract a node.
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
multiset()=default
Default constructor creates no elements.
iterator insert(const value_type &__x)
Inserts an element into the multiset.
reverse_iterator rbegin() const noexcept
reverse_iterator rend() const noexcept
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the multiset.
void insert(_InputIterator __first, _InputIterator __last)
A template function that tries to insert a range of elements.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
multiset(multiset &&)=default
Multiset move constructor.
auto upper_bound(const _Kt &__x) -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
Finds the end of a subsequence matching given key.
iterator find(const key_type &__x)
Tries to locate an element in a set.
multiset & operator=(initializer_list< value_type > __l)
Multiset list assignment operator.
auto find(const _Kt &__x) -> decltype(iterator{_M_t._M_find_tr(__x)})
Tries to locate an element in a set.
node_type extract(const key_type &__x)
Extract a node.
auto lower_bound(const _Kt &__x) const -> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
Finds the beginning of a subsequence matching given key.
size_type count(const key_type &__x) const
Finds the number of elements with given key.
size_type size() const noexcept
Returns the size of the set.
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
_GLIBCXX_ABI_TAG_CXX11 iterator erase(const_iterator __position)
Erases an element from a multiset.
iterator cend() const noexcept
multiset & operator=(multiset &&)=default
Move assignment operator.
allocator_type get_allocator() const noexcept
Returns the memory allocation object.
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
auto equal_range(const _Kt &__x) const -> decltype(pair< iterator, iterator >(_M_t._M_equal_range_tr(__x)))
Finds a subsequence matching given key.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
key_compare key_comp() const
Returns the comparison object.
multiset(_InputIterator __first, _InputIterator __last)
Builds a multiset from a range.
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
iterator insert(const_iterator __hint, node_type &&__nh)
Re-insert an extracted node.
iterator insert(const_iterator __position, const value_type &__x)
Inserts an element into the multiset.
iterator begin() const noexcept
multiset(initializer_list< value_type > __l, const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())
Builds a multiset from an initializer_list.
auto equal_range(const _Kt &__x) -> decltype(pair< iterator, iterator >(_M_t._M_equal_range_tr(__x)))
Finds a subsequence matching given key.
const_iterator find(const key_type &__x) const
Tries to locate an element in a set.
auto lower_bound(const _Kt &__x) -> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
Finds the beginning of a subsequence matching given key.
multiset(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a multiset from a range.
multiset(const allocator_type &__a)
Allocator-extended default constructor.
size_type max_size() const noexcept
Returns the maximum size of the set.
multiset(const multiset &)=default
Multiset copy constructor.
iterator end() const noexcept
Struct holding two objects of arbitrary type.
Uniform interface to C++98 and C++11 allocators.