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 const __type_identity_t<allocator_type>& __a)
253 : _M_t(__m._M_t, _Key_alloc_type(__a)) { }
258 && _Alloc_traits::_S_always_equal())
259 : _M_t(
std::
move(__m._M_t), _Key_alloc_type(__a)) { }
263 : _M_t(_Key_alloc_type(__a))
264 { _M_t._M_insert_range_equal(__l.begin(), __l.end()); }
267 template<
typename _InputIterator>
268 multiset(_InputIterator __first, _InputIterator __last,
269 const allocator_type& __a)
270 : _M_t(_Key_alloc_type(__a))
271 { _M_t._M_insert_range_equal(__first, __last); }
286#if __cplusplus < 201103L
315 _M_t._M_assign_equal(__l.begin(), __l.end());
325 {
return _M_t.key_comp(); }
329 {
return _M_t.key_comp(); }
333 {
return allocator_type(_M_t.get_allocator()); }
342 {
return _M_t.begin(); }
350 end() const _GLIBCXX_NOEXCEPT
351 {
return _M_t.end(); }
360 {
return _M_t.rbegin(); }
369 {
return _M_t.rend(); }
371#if __cplusplus >= 201103L
379 {
return _M_t.begin(); }
388 {
return _M_t.end(); }
397 {
return _M_t.rbegin(); }
406 {
return _M_t.rend(); }
410 _GLIBCXX_NODISCARD
bool
412 {
return _M_t.empty(); }
417 {
return _M_t.size(); }
422 {
return _M_t.max_size(); }
439 _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
440 { _M_t.swap(__x._M_t); }
443#if __cplusplus >= 201103L
456 template<
typename... _Args>
459 {
return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); }
482 template<
typename... _Args>
486 return _M_t._M_emplace_hint_equal(__pos,
487 std::forward<_Args>(__args)...);
504 {
return _M_t._M_insert_equal(__x); }
506#if __cplusplus >= 201103L
509 {
return _M_t._M_insert_equal(
std::move(__x)); }
533 insert(const_iterator __position,
const value_type& __x)
534 {
return _M_t._M_insert_equal_(__position, __x); }
536#if __cplusplus >= 201103L
538 insert(const_iterator __position, value_type&& __x)
539 {
return _M_t._M_insert_equal_(__position,
std::move(__x)); }
550 template<
typename _InputIterator>
552 insert(_InputIterator __first, _InputIterator __last)
553 { _M_t._M_insert_range_equal(__first, __last); }
555#if __cplusplus >= 201103L
565 { this->
insert(__l.begin(), __l.end()); }
568#if __cplusplus > 201402L
573 __glibcxx_assert(__pos !=
end());
574 return _M_t.extract(__pos);
580 {
return _M_t.extract(__x); }
585 {
return _M_t._M_reinsert_node_equal(
std::move(__nh)); }
589 insert(const_iterator __hint, node_type&& __nh)
590 {
return _M_t._M_reinsert_node_hint_equal(__hint,
std::move(__nh)); }
592 template<
typename,
typename>
593 friend struct std::_Rb_tree_merge_helper;
595 template<
typename _Compare1>
599 using _Merge_helper = _Rb_tree_merge_helper<multiset, _Compare1>;
600 _M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source));
603 template<
typename _Compare1>
605 merge(multiset<_Key, _Compare1, _Alloc>&& __source)
608 template<
typename _Compare1>
610 merge(set<_Key, _Compare1, _Alloc>& __source)
612 using _Merge_helper = _Rb_tree_merge_helper<multiset, _Compare1>;
613 _M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source));
616 template<
typename _Compare1>
618 merge(set<_Key, _Compare1, _Alloc>&& __source)
622#if __cplusplus >= 201103L
638 _GLIBCXX_ABI_TAG_CXX11
641 {
return _M_t.erase(__position); }
655 { _M_t.erase(__position); }
671 {
return _M_t.erase(__x); }
673#if __cplusplus >= 201103L
690 _GLIBCXX_ABI_TAG_CXX11
692 erase(const_iterator __first, const_iterator __last)
693 {
return _M_t.erase(__first, __last); }
709 { _M_t.erase(__first, __last); }
732 {
return _M_t.count(__x); }
734#if __cplusplus > 201103L
735 template<
typename _Kt>
737 count(
const _Kt& __x)
const ->
decltype(_M_t._M_count_tr(__x))
738 {
return _M_t._M_count_tr(__x); }
742#if __cplusplus > 201703L
751 {
return _M_t.find(__x) != _M_t.end(); }
753 template<
typename _Kt>
756 ->
decltype(_M_t._M_find_tr(__x), void(),
true)
757 {
return _M_t._M_find_tr(__x) != _M_t.end(); }
777 {
return _M_t.find(__x); }
780 find(
const key_type& __x)
const
781 {
return _M_t.find(__x); }
783#if __cplusplus > 201103L
784 template<
typename _Kt>
787 ->
decltype(iterator{_M_t._M_find_tr(__x)})
788 {
return iterator{_M_t._M_find_tr(__x)}; }
790 template<
typename _Kt>
793 ->
decltype(const_iterator{_M_t._M_find_tr(__x)})
794 {
return const_iterator{_M_t._M_find_tr(__x)}; }
812 {
return _M_t.lower_bound(__x); }
816 {
return _M_t.lower_bound(__x); }
818#if __cplusplus > 201103L
819 template<
typename _Kt>
822 ->
decltype(iterator(_M_t._M_lower_bound_tr(__x)))
823 {
return iterator(_M_t._M_lower_bound_tr(__x)); }
825 template<
typename _Kt>
828 ->
decltype(iterator(_M_t._M_lower_bound_tr(__x)))
829 {
return iterator(_M_t._M_lower_bound_tr(__x)); }
842 {
return _M_t.upper_bound(__x); }
846 {
return _M_t.upper_bound(__x); }
848#if __cplusplus > 201103L
849 template<
typename _Kt>
852 ->
decltype(iterator(_M_t._M_upper_bound_tr(__x)))
853 {
return iterator(_M_t._M_upper_bound_tr(__x)); }
855 template<
typename _Kt>
858 ->
decltype(iterator(_M_t._M_upper_bound_tr(__x)))
859 {
return iterator(_M_t._M_upper_bound_tr(__x)); }
881 {
return _M_t.equal_range(__x); }
885 {
return _M_t.equal_range(__x); }
887#if __cplusplus > 201103L
888 template<
typename _Kt>
894 template<
typename _Kt>
902 template<
typename _K1,
typename _C1,
typename _A1>
907#if __cpp_lib_three_way_comparison
908 template<
typename _K1,
typename _C1,
typename _A1>
909 friend __detail::__synth3way_t<_K1>
913 template<
typename _K1,
typename _C1,
typename _A1>
920#if __cpp_deduction_guides >= 201606
922 template<
typename _InputIterator,
924 less<typename iterator_traits<_InputIterator>::value_type>,
925 typename _Allocator =
926 allocator<typename iterator_traits<_InputIterator>::value_type>,
927 typename = _RequireInputIter<_InputIterator>,
928 typename = _RequireNotAllocator<_Compare>,
929 typename = _RequireAllocator<_Allocator>>
930 multiset(_InputIterator, _InputIterator,
931 _Compare = _Compare(), _Allocator = _Allocator())
932 -> multiset<typename iterator_traits<_InputIterator>::value_type,
933 _Compare, _Allocator>;
935 template<
typename _Key,
936 typename _Compare = less<_Key>,
937 typename _Allocator = allocator<_Key>,
938 typename = _RequireNotAllocator<_Compare>,
939 typename = _RequireAllocator<_Allocator>>
940 multiset(initializer_list<_Key>,
941 _Compare = _Compare(), _Allocator = _Allocator())
942 -> multiset<_Key, _Compare, _Allocator>;
944 template<
typename _InputIterator,
typename _Allocator,
945 typename = _RequireInputIter<_InputIterator>,
946 typename = _RequireAllocator<_Allocator>>
947 multiset(_InputIterator, _InputIterator, _Allocator)
948 -> multiset<typename iterator_traits<_InputIterator>::value_type,
949 less<typename iterator_traits<_InputIterator>::value_type>,
952 template<
typename _Key,
typename _Allocator,
953 typename = _RequireAllocator<_Allocator>>
954 multiset(initializer_list<_Key>, _Allocator)
955 -> multiset<_Key, less<_Key>, _Allocator>;
970 template<
typename _Key,
typename _Compare,
typename _Alloc>
974 {
return __x._M_t == __y._M_t; }
976#if __cpp_lib_three_way_comparison
991 template<
typename _Key,
typename _Compare,
typename _Alloc>
992 inline __detail::__synth3way_t<_Key>
993 operator<=>(
const multiset<_Key, _Compare, _Alloc>& __x,
994 const multiset<_Key, _Compare, _Alloc>& __y)
995 {
return __x._M_t <=> __y._M_t; }
1008 template<
typename _Key,
typename _Compare,
typename _Alloc>
1012 {
return __x._M_t < __y._M_t; }
1015 template<
typename _Key,
typename _Compare,
typename _Alloc>
1019 {
return !(__x == __y); }
1022 template<
typename _Key,
typename _Compare,
typename _Alloc>
1026 {
return __y < __x; }
1029 template<
typename _Key,
typename _Compare,
typename _Alloc>
1033 {
return !(__y < __x); }
1036 template<
typename _Key,
typename _Compare,
typename _Alloc>
1040 {
return !(__x < __y); }
1044 template<
typename _Key,
typename _Compare,
typename _Alloc>
1048 _GLIBCXX_NOEXCEPT_IF(
noexcept(__x.swap(__y)))
1051_GLIBCXX_END_NAMESPACE_CONTAINER
1053#if __cplusplus > 201402L
1055 template<
typename _Val,
typename _Cmp1,
typename _Alloc,
typename _Cmp2>
1057 _Rb_tree_merge_helper<_GLIBCXX_STD_C::multiset<_Val, _Cmp1, _Alloc>,
1061 friend class _GLIBCXX_STD_C::multiset<_Val, _Cmp1, _Alloc>;
1064 _S_get_tree(_GLIBCXX_STD_C::set<_Val, _Cmp2, _Alloc>& __set)
1065 {
return __set._M_t; }
1068 _S_get_tree(_GLIBCXX_STD_C::multiset<_Val, _Cmp2, _Alloc>& __set)
1069 {
return __set._M_t; }
1073_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.
Struct holding two objects of arbitrary type.
A standard container made up of elements, which can be retrieved in logarithmic time.
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.
auto contains(const _Kt &__x) const -> decltype(_M_t._M_find_tr(__x), void(), true)
Finds whether an element with the given key exists.
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.
multiset(const multiset &__m, const __type_identity_t< allocator_type > &__a)
Allocator-extended copy 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.
multiset(multiset &&__m, const __type_identity_t< allocator_type > &__a) noexcept(is_nothrow_copy_constructible< _Compare >::value &&_Alloc_traits::_S_always_equal())
Allocator-extended move constructor.
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.
bool contains(const key_type &__x) const
Finds whether an element with the given key exists.
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
Uniform interface to C++98 and C++11 allocators.