56 #ifndef _STL_MULTISET_H 57 #define _STL_MULTISET_H 1 60 #if __cplusplus >= 201103L 64 namespace std _GLIBCXX_VISIBILITY(default)
66 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
68 template<
typename _Key,
typename _Compare,
typename _Alloc>
93 template <
typename _Key,
typename _Compare = std::less<_Key>,
94 typename _Alloc = std::allocator<_Key> >
98 typedef typename _Alloc::value_type _Alloc_value_type;
99 __glibcxx_class_requires(_Key, _SGIAssignableConcept)
100 __glibcxx_class_requires4(_Compare,
bool, _Key, _Key,
101 _BinaryFunctionConcept)
102 __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
106 typedef _Key key_type;
107 typedef _Key value_type;
108 typedef _Compare key_compare;
109 typedef _Compare value_compare;
110 typedef _Alloc allocator_type;
115 rebind<_Key>::other _Key_alloc_type;
117 typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
118 key_compare, _Key_alloc_type> _Rep_type;
125 typedef typename _Alloc_traits::pointer pointer;
126 typedef typename _Alloc_traits::const_pointer const_pointer;
127 typedef typename _Alloc_traits::reference reference;
128 typedef typename _Alloc_traits::const_reference const_reference;
132 typedef typename _Rep_type::const_iterator iterator;
133 typedef typename _Rep_type::const_iterator const_iterator;
136 typedef typename _Rep_type::size_type size_type;
137 typedef typename _Rep_type::difference_type difference_type;
139 #if __cplusplus > 201402L 140 using node_type =
typename _Rep_type::node_type;
147 #if __cplusplus < 201103L 160 const allocator_type& __a = allocator_type())
161 : _M_t(__comp, _Key_alloc_type(__a)) { }
172 template<
typename _InputIterator>
173 multiset(_InputIterator __first, _InputIterator __last)
175 { _M_t._M_insert_equal(__first, __last); }
188 template<
typename _InputIterator>
189 multiset(_InputIterator __first, _InputIterator __last,
190 const _Compare& __comp,
191 const allocator_type& __a = allocator_type())
192 : _M_t(__comp, _Key_alloc_type(__a))
193 { _M_t._M_insert_equal(__first, __last); }
200 #if __cplusplus < 201103L 226 const _Compare& __comp = _Compare(),
227 const allocator_type& __a = allocator_type())
228 : _M_t(__comp, _Key_alloc_type(__a))
229 { _M_t._M_insert_equal(__l.begin(), __l.end()); }
234 : _M_t(_Compare(), _Key_alloc_type(__a)) { }
238 : _M_t(__m._M_t, _Key_alloc_type(__a)) { }
242 noexcept(is_nothrow_copy_constructible<_Compare>::value
243 && _Alloc_traits::_S_always_equal())
244 : _M_t(
std::move(__m._M_t), _Key_alloc_type(__a)) { }
248 : _M_t(_Compare(), _Key_alloc_type(__a))
249 { _M_t._M_insert_equal(__l.begin(), __l.end()); }
252 template<
typename _InputIterator>
253 multiset(_InputIterator __first, _InputIterator __last,
254 const allocator_type& __a)
255 : _M_t(_Compare(), _Key_alloc_type(__a))
256 { _M_t._M_insert_equal(__first, __last); }
271 #if __cplusplus < 201103L 300 _M_t._M_assign_equal(__l.begin(), __l.end());
310 {
return _M_t.key_comp(); }
314 {
return _M_t.key_comp(); }
318 {
return allocator_type(_M_t.get_allocator()); }
327 {
return _M_t.begin(); }
335 end() const _GLIBCXX_NOEXCEPT
336 {
return _M_t.end(); }
345 {
return _M_t.rbegin(); }
354 {
return _M_t.rend(); }
356 #if __cplusplus >= 201103L 364 {
return _M_t.begin(); }
373 {
return _M_t.end(); }
382 {
return _M_t.rbegin(); }
391 {
return _M_t.rend(); }
397 {
return _M_t.empty(); }
402 {
return _M_t.size(); }
407 {
return _M_t.max_size(); }
424 _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
425 { _M_t.swap(__x._M_t); }
428 #if __cplusplus >= 201103L 441 template<
typename... _Args>
444 {
return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); }
467 template<
typename... _Args>
471 return _M_t._M_emplace_hint_equal(__pos,
472 std::forward<_Args>(__args)...);
489 {
return _M_t._M_insert_equal(__x); }
491 #if __cplusplus >= 201103L 494 {
return _M_t._M_insert_equal(std::move(__x)); }
518 insert(const_iterator __position,
const value_type& __x)
519 {
return _M_t._M_insert_equal_(__position, __x); }
521 #if __cplusplus >= 201103L 523 insert(const_iterator __position, value_type&& __x)
524 {
return _M_t._M_insert_equal_(__position, std::move(__x)); }
535 template<
typename _InputIterator>
537 insert(_InputIterator __first, _InputIterator __last)
538 { _M_t._M_insert_equal(__first, __last); }
540 #if __cplusplus >= 201103L 550 { this->
insert(__l.begin(), __l.end()); }
553 #if __cplusplus > 201402L 556 extract(const_iterator __pos)
558 __glibcxx_assert(__pos !=
end());
559 return _M_t.extract(__pos);
564 extract(
const key_type& __x)
565 {
return _M_t.extract(__x); }
570 {
return _M_t._M_reinsert_node_equal(std::move(__nh)); }
574 insert(const_iterator __hint, node_type&& __nh)
575 {
return _M_t._M_reinsert_node_hint_equal(__hint, std::move(__nh)); }
577 template<
typename,
typename>
578 friend class _Rb_tree_merge_helper;
580 template<
typename _Compare1>
584 using _Merge_helper = _Rb_tree_merge_helper<multiset, _Compare1>;
585 _M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source));
588 template<
typename _Compare1>
593 template<
typename _Compare1>
597 using _Merge_helper = _Rb_tree_merge_helper<multiset, _Compare1>;
598 _M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source));
601 template<
typename _Compare1>
607 #if __cplusplus >= 201103L 623 _GLIBCXX_ABI_TAG_CXX11
626 {
return _M_t.erase(__position); }
639 erase(iterator __position)
640 { _M_t.erase(__position); }
656 {
return _M_t.erase(__x); }
658 #if __cplusplus >= 201103L 675 _GLIBCXX_ABI_TAG_CXX11
677 erase(const_iterator __first, const_iterator __last)
678 {
return _M_t.erase(__first, __last); }
693 erase(iterator __first, iterator __last)
694 { _M_t.erase(__first, __last); }
717 {
return _M_t.count(__x); }
719 #if __cplusplus > 201103L 720 template<
typename _Kt>
722 count(
const _Kt& __x)
const -> decltype(_M_t._M_count_tr(__x))
723 {
return _M_t._M_count_tr(__x); }
743 {
return _M_t.find(__x); }
746 find(
const key_type& __x)
const 747 {
return _M_t.find(__x); }
749 #if __cplusplus > 201103L 750 template<
typename _Kt>
753 -> decltype(iterator{_M_t._M_find_tr(__x)})
754 {
return iterator{_M_t._M_find_tr(__x)}; }
756 template<
typename _Kt>
759 -> decltype(const_iterator{_M_t._M_find_tr(__x)})
760 {
return const_iterator{_M_t._M_find_tr(__x)}; }
778 {
return _M_t.lower_bound(__x); }
782 {
return _M_t.lower_bound(__x); }
784 #if __cplusplus > 201103L 785 template<
typename _Kt>
788 -> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
789 {
return iterator(_M_t._M_lower_bound_tr(__x)); }
791 template<
typename _Kt>
794 -> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
795 {
return iterator(_M_t._M_lower_bound_tr(__x)); }
808 {
return _M_t.upper_bound(__x); }
812 {
return _M_t.upper_bound(__x); }
814 #if __cplusplus > 201103L 815 template<
typename _Kt>
818 -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
819 {
return iterator(_M_t._M_upper_bound_tr(__x)); }
821 template<
typename _Kt>
824 -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
825 {
return iterator(_M_t._M_upper_bound_tr(__x)); }
847 {
return _M_t.equal_range(__x); }
851 {
return _M_t.equal_range(__x); }
853 #if __cplusplus > 201103L 854 template<
typename _Kt>
860 template<
typename _Kt>
868 template<
typename _K1,
typename _C1,
typename _A1>
873 template<
typename _K1,
typename _C1,
typename _A1>
875 operator< (const multiset<_K1, _C1, _A1>&,
890 template<
typename _Key,
typename _Compare,
typename _Alloc>
894 {
return __x._M_t == __y._M_t; }
907 template<
typename _Key,
typename _Compare,
typename _Alloc>
909 operator<(const multiset<_Key, _Compare, _Alloc>& __x,
911 {
return __x._M_t < __y._M_t; }
914 template<
typename _Key,
typename _Compare,
typename _Alloc>
918 {
return !(__x == __y); }
921 template<
typename _Key,
typename _Compare,
typename _Alloc>
925 {
return __y < __x; }
928 template<
typename _Key,
typename _Compare,
typename _Alloc>
930 operator<=(const multiset<_Key, _Compare, _Alloc>& __x,
932 {
return !(__y < __x); }
935 template<
typename _Key,
typename _Compare,
typename _Alloc>
939 {
return !(__x < __y); }
942 template<
typename _Key,
typename _Compare,
typename _Alloc>
946 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
949 _GLIBCXX_END_NAMESPACE_CONTAINER
951 #if __cplusplus > 201402L 952 _GLIBCXX_BEGIN_NAMESPACE_VERSION
954 template<
typename _Val,
typename _Cmp1,
typename _Alloc,
typename _Cmp2>
956 _Rb_tree_merge_helper<_GLIBCXX_STD_C::multiset<_Val, _Cmp1, _Alloc>,
960 friend class _GLIBCXX_STD_C::multiset<_Val, _Cmp1, _Alloc>;
963 _S_get_tree(_GLIBCXX_STD_C::set<_Val, _Cmp2, _Alloc>& __set)
964 {
return __set._M_t; }
967 _S_get_tree(_GLIBCXX_STD_C::multiset<_Val, _Cmp2, _Alloc>& __set)
968 {
return __set._M_t; }
970 _GLIBCXX_END_NAMESPACE_VERSION
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the multiset.
void swap(multiset &__x) noexcept(/*conditional */)
Swaps data with another multiset.
reverse_iterator crend() const noexcept
bool operator==(const multiset< _Key, _Compare, _Alloc > &__x, const multiset< _Key, _Compare, _Alloc > &__y)
Multiset equality comparison.
void insert(_InputIterator __first, _InputIterator __last)
A template function that tries to insert a range of elements.
bool operator>(const multiset< _Key, _Compare, _Alloc > &__x, const multiset< _Key, _Compare, _Alloc > &__y)
Returns y < x.
iterator cbegin() const noexcept
size_type count(const key_type &__x) const
Finds the number of elements with given key.
iterator end() const noexcept
bool empty() const noexcept
Returns true if the set is empty.
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
ISO C++ entities toplevel namespace is std.
multiset(const multiset &__m, const allocator_type &__a)
Allocator-extended copy constructor.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
reverse_iterator rend() const noexcept
size_type size() const noexcept
Returns the size of the set.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
key_compare key_comp() const
Returns the comparison object.
multiset()=default
Default constructor creates no elements.
reverse_iterator rbegin() const noexcept
_GLIBCXX_ABI_TAG_CXX11 iterator erase(const_iterator __position)
Erases an element from a multiset.
multiset(const allocator_type &__a)
Allocator-extended default constructor.
multiset(_InputIterator __first, _InputIterator __last)
Builds a multiset from a range.
multiset & operator=(initializer_list< value_type > __l)
Multiset list assignment operator.
multiset(initializer_list< value_type > __l, const allocator_type &__a)
Allocator-extended initialier-list constructor.
iterator find(const key_type &__x)
Tries to locate an element in a set.
A standard container made up of elements, which can be retrieved in logarithmic time.
iterator insert(const_iterator __position, const value_type &__x)
Inserts an element into the multiset.
bool operator>=(const multiset< _Key, _Compare, _Alloc > &__x, const multiset< _Key, _Compare, _Alloc > &__y)
Returns !(x < y)
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
value_compare value_comp() const
Returns the comparison object.
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.
multiset(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a multiset from a range.
auto lower_bound(const _Kt &__x) -> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
Finds the beginning of a subsequence matching given key.
iterator cend() const noexcept
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.
multiset(multiset &&__m, const allocator_type &__a) noexcept(is_nothrow_copy_constructible< _Compare >::value &&_Alloc_traits::_S_always_equal())
Allocator-extended 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 emplace_hint(const_iterator __pos, _Args &&... __args)
Builds and inserts an element into the multiset.
A standard container made up of unique keys, which can be retrieved in logarithmic time...
bool operator!=(const multiset< _Key, _Compare, _Alloc > &__x, const multiset< _Key, _Compare, _Alloc > &__y)
Returns !(x == y).
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.
allocator_type get_allocator() const noexcept
Returns the memory allocation object.
auto count(const _Kt &__x) const -> decltype(_M_t._M_count_tr(__x))
Finds the number of elements with given key.
reverse_iterator crbegin() const noexcept
Struct holding two objects of arbitrary type.
iterator lower_bound(const key_type &__x)
Finds the beginning 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.
multiset(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a multiset with no elements.
multiset & operator=(const multiset &)=default
Multiset assignment operator.
const_iterator find(const key_type &__x) const
Tries to locate an element in a set.
iterator begin() const noexcept
auto equal_range(const _Kt &__x) -> decltype(pair< iterator, iterator >(_M_t._M_equal_range_tr(__x)))
Finds a subsequence matching given key.
auto find(const _Kt &__x) const -> decltype(const_iterator
Tries to locate an element in a set.
iterator insert(const value_type &__x)
Inserts an element into the multiset.
Uniform interface to C++98 and C++11 allocators.
size_type max_size() const noexcept
Returns the maximum size of the set.
_GLIBCXX_ABI_TAG_CXX11 iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a multiset.
multiset(initializer_list< value_type > __l, const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())
Builds a multiset from an initializer_list.
auto find(const _Kt &__x) -> decltype(iterator
Tries to locate an element in a set.
size_type erase(const key_type &__x)
Erases elements according to the provided key.