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); }
205 #if __cplusplus >= 201103L 214 noexcept(is_nothrow_copy_constructible<_Compare>::value)
215 : _M_t(
std::move(__x._M_t)) { }
228 const _Compare& __comp = _Compare(),
229 const allocator_type& __a = allocator_type())
230 : _M_t(__comp, _Key_alloc_type(__a))
231 { _M_t._M_insert_equal(__l.begin(), __l.end()); }
236 : _M_t(_Compare(), _Key_alloc_type(__a)) { }
240 : _M_t(__m._M_t, _Key_alloc_type(__a)) { }
244 noexcept(is_nothrow_copy_constructible<_Compare>::value
245 && _Alloc_traits::_S_always_equal())
246 : _M_t(
std::move(__m._M_t), _Key_alloc_type(__a)) { }
250 : _M_t(_Compare(), _Key_alloc_type(__a))
251 { _M_t._M_insert_equal(__l.begin(), __l.end()); }
254 template<
typename _InputIterator>
255 multiset(_InputIterator __first, _InputIterator __last,
256 const allocator_type& __a)
257 : _M_t(_Compare(), _Key_alloc_type(__a))
258 { _M_t._M_insert_equal(__first, __last); }
276 #if __cplusplus >= 201103L 295 _M_t._M_assign_equal(__l.begin(), __l.end());
305 {
return _M_t.key_comp(); }
309 {
return _M_t.key_comp(); }
313 {
return allocator_type(_M_t.get_allocator()); }
322 {
return _M_t.begin(); }
330 end() const _GLIBCXX_NOEXCEPT
331 {
return _M_t.end(); }
340 {
return _M_t.rbegin(); }
349 {
return _M_t.rend(); }
351 #if __cplusplus >= 201103L 359 {
return _M_t.begin(); }
368 {
return _M_t.end(); }
377 {
return _M_t.rbegin(); }
386 {
return _M_t.rend(); }
392 {
return _M_t.empty(); }
397 {
return _M_t.size(); }
402 {
return _M_t.max_size(); }
419 _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
420 { _M_t.swap(__x._M_t); }
423 #if __cplusplus >= 201103L 436 template<
typename... _Args>
439 {
return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); }
462 template<
typename... _Args>
466 return _M_t._M_emplace_hint_equal(__pos,
467 std::forward<_Args>(__args)...);
484 {
return _M_t._M_insert_equal(__x); }
486 #if __cplusplus >= 201103L 489 {
return _M_t._M_insert_equal(std::move(__x)); }
513 insert(const_iterator __position,
const value_type& __x)
514 {
return _M_t._M_insert_equal_(__position, __x); }
516 #if __cplusplus >= 201103L 518 insert(const_iterator __position, value_type&& __x)
519 {
return _M_t._M_insert_equal_(__position, std::move(__x)); }
530 template<
typename _InputIterator>
532 insert(_InputIterator __first, _InputIterator __last)
533 { _M_t._M_insert_equal(__first, __last); }
535 #if __cplusplus >= 201103L 545 { this->
insert(__l.begin(), __l.end()); }
548 #if __cplusplus > 201402L 551 extract(const_iterator __pos)
553 __glibcxx_assert(__pos !=
end());
554 return _M_t.extract(__pos);
559 extract(
const key_type& __x)
560 {
return _M_t.extract(__x); }
565 {
return _M_t._M_reinsert_node_equal(std::move(__nh)); }
569 insert(const_iterator __hint, node_type&& __nh)
570 {
return _M_t._M_reinsert_node_hint_equal(__hint, std::move(__nh)); }
572 template<
typename,
typename>
573 friend class _Rb_tree_merge_helper;
575 template<
typename _Compare1>
579 using _Merge_helper = _Rb_tree_merge_helper<multiset, _Compare1>;
580 _M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source));
583 template<
typename _Compare1>
588 template<
typename _Compare1>
592 using _Merge_helper = _Rb_tree_merge_helper<multiset, _Compare1>;
593 _M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source));
596 template<
typename _Compare1>
602 #if __cplusplus >= 201103L 618 _GLIBCXX_ABI_TAG_CXX11
621 {
return _M_t.erase(__position); }
634 erase(iterator __position)
635 { _M_t.erase(__position); }
651 {
return _M_t.erase(__x); }
653 #if __cplusplus >= 201103L 670 _GLIBCXX_ABI_TAG_CXX11
672 erase(const_iterator __first, const_iterator __last)
673 {
return _M_t.erase(__first, __last); }
688 erase(iterator __first, iterator __last)
689 { _M_t.erase(__first, __last); }
712 {
return _M_t.count(__x); }
714 #if __cplusplus > 201103L 715 template<
typename _Kt>
717 count(
const _Kt& __x)
const -> decltype(_M_t._M_count_tr(__x))
718 {
return _M_t._M_count_tr(__x); }
738 {
return _M_t.find(__x); }
741 find(
const key_type& __x)
const 742 {
return _M_t.find(__x); }
744 #if __cplusplus > 201103L 745 template<
typename _Kt>
748 -> decltype(iterator{_M_t._M_find_tr(__x)})
749 {
return iterator{_M_t._M_find_tr(__x)}; }
751 template<
typename _Kt>
754 -> decltype(const_iterator{_M_t._M_find_tr(__x)})
755 {
return const_iterator{_M_t._M_find_tr(__x)}; }
773 {
return _M_t.lower_bound(__x); }
777 {
return _M_t.lower_bound(__x); }
779 #if __cplusplus > 201103L 780 template<
typename _Kt>
783 -> decltype(_M_t._M_lower_bound_tr(__x))
784 {
return _M_t._M_lower_bound_tr(__x); }
786 template<
typename _Kt>
789 -> decltype(_M_t._M_lower_bound_tr(__x))
790 {
return _M_t._M_lower_bound_tr(__x); }
803 {
return _M_t.upper_bound(__x); }
807 {
return _M_t.upper_bound(__x); }
809 #if __cplusplus > 201103L 810 template<
typename _Kt>
813 -> decltype(_M_t._M_upper_bound_tr(__x))
814 {
return _M_t._M_upper_bound_tr(__x); }
816 template<
typename _Kt>
819 -> decltype(_M_t._M_upper_bound_tr(__x))
820 {
return _M_t._M_upper_bound_tr(__x); }
842 {
return _M_t.equal_range(__x); }
846 {
return _M_t.equal_range(__x); }
848 #if __cplusplus > 201103L 849 template<
typename _Kt>
852 -> decltype(_M_t._M_equal_range_tr(__x))
853 {
return _M_t._M_equal_range_tr(__x); }
855 template<
typename _Kt>
858 -> decltype(_M_t._M_equal_range_tr(__x))
859 {
return _M_t._M_equal_range_tr(__x); }
863 template<
typename _K1,
typename _C1,
typename _A1>
868 template<
typename _K1,
typename _C1,
typename _A1>
870 operator< (const multiset<_K1, _C1, _A1>&,
885 template<
typename _Key,
typename _Compare,
typename _Alloc>
889 {
return __x._M_t == __y._M_t; }
902 template<
typename _Key,
typename _Compare,
typename _Alloc>
904 operator<(const multiset<_Key, _Compare, _Alloc>& __x,
906 {
return __x._M_t < __y._M_t; }
909 template<
typename _Key,
typename _Compare,
typename _Alloc>
913 {
return !(__x == __y); }
916 template<
typename _Key,
typename _Compare,
typename _Alloc>
920 {
return __y < __x; }
923 template<
typename _Key,
typename _Compare,
typename _Alloc>
925 operator<=(const multiset<_Key, _Compare, _Alloc>& __x,
927 {
return !(__y < __x); }
930 template<
typename _Key,
typename _Compare,
typename _Alloc>
934 {
return !(__x < __y); }
937 template<
typename _Key,
typename _Compare,
typename _Alloc>
941 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
944 _GLIBCXX_END_NAMESPACE_CONTAINER
946 #if __cplusplus > 201402L 947 _GLIBCXX_BEGIN_NAMESPACE_VERSION
949 template<
typename _Val,
typename _Cmp1,
typename _Alloc,
typename _Cmp2>
951 _Rb_tree_merge_helper<_GLIBCXX_STD_C::multiset<_Val, _Cmp1, _Alloc>,
955 friend class _GLIBCXX_STD_C::multiset<_Val, _Cmp1, _Alloc>;
958 _S_get_tree(_GLIBCXX_STD_C::set<_Val, _Cmp2, _Alloc>& __set)
959 {
return __set._M_t; }
962 _S_get_tree(_GLIBCXX_STD_C::multiset<_Val, _Cmp2, _Alloc>& __set)
963 {
return __set._M_t; }
965 _GLIBCXX_END_NAMESPACE_VERSION
A standard container made up of unique keys, which can be retrieved in logarithmic time...
reverse_iterator crbegin() const noexcept
reverse_iterator crend() const noexcept
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
auto upper_bound(const _Kt &__x) -> decltype(_M_t._M_upper_bound_tr(__x))
Finds the end of a subsequence matching given key.
multiset & operator=(initializer_list< value_type > __l)
Multiset list assignment operator.
multiset(_InputIterator __first, _InputIterator __last)
Builds a multiset from a range.
bool operator==(const multiset< _Key, _Compare, _Alloc > &__x, const multiset< _Key, _Compare, _Alloc > &__y)
Multiset equality comparison.
multiset(_InputIterator __first, _InputIterator __last, const allocator_type &__a)
Allocator-extended range constructor.
bool operator>(const multiset< _Key, _Compare, _Alloc > &__x, const multiset< _Key, _Compare, _Alloc > &__y)
Returns y < x.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the multiset.
auto equal_range(const _Kt &__x) -> decltype(_M_t._M_equal_range_tr(__x))
Finds a subsequence matching given key.
auto upper_bound(const _Kt &__x) const -> decltype(_M_t._M_upper_bound_tr(__x))
Finds the end 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 find(const _Kt &__x) -> decltype(iterator
Tries to locate an element in a set.
Uniform interface to C++98 and C++11 allocators.
multiset(const multiset &__x)
Multiset copy constructor.
void swap(multiset &__x) noexcept(/*conditional */)
Swaps data with another multiset.
multiset(initializer_list< value_type > __l, const allocator_type &__a)
Allocator-extended initialier-list constructor.
size_type max_size() const noexcept
Returns the maximum size of the set.
bool empty() const noexcept
Returns true if the set is empty.
auto lower_bound(const _Kt &__x) const -> decltype(_M_t._M_lower_bound_tr(__x))
Finds the beginning of a subsequence matching given key.
iterator emplace(_Args &&... __args)
Builds and inserts an element into the multiset.
ISO C++ entities toplevel namespace is std.
value_compare value_comp() const
Returns the comparison object.
iterator end() const noexcept
auto count(const _Kt &__x) const -> decltype(_M_t._M_count_tr(__x))
Finds the number of elements with given key.
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
key_compare key_comp() const
Returns the comparison object.
_GLIBCXX_ABI_TAG_CXX11 iterator erase(const_iterator __position)
Erases an element from a multiset.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
reverse_iterator rend() const noexcept
bool operator>=(const multiset< _Key, _Compare, _Alloc > &__x, const multiset< _Key, _Compare, _Alloc > &__y)
Returns !(x < y)
auto lower_bound(const _Kt &__x) -> decltype(_M_t._M_lower_bound_tr(__x))
Finds the beginning of a subsequence matching given key.
multiset(const multiset &__m, const allocator_type &__a)
Allocator-extended copy constructor.
multiset(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a multiset from a range.
auto find(const _Kt &__x) const -> decltype(const_iterator
Tries to locate an element in a set.
size_type count(const key_type &__x) const
Finds the number of elements with given key.
Struct holding two objects of arbitrary type.
const_iterator find(const key_type &__x) const
Tries to locate an element in a set.
reverse_iterator rbegin() const noexcept
iterator emplace_hint(const_iterator __pos, _Args &&... __args)
Builds and inserts an element into the multiset.
multiset(initializer_list< value_type > __l, const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())
Builds a multiset from an initializer_list.
multiset()=default
Default constructor creates no elements.
multiset(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a multiset with no elements.
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.
multiset & operator=(const multiset &__x)
Multiset assignment operator.
bool operator!=(const multiset< _Key, _Compare, _Alloc > &__x, const multiset< _Key, _Compare, _Alloc > &__y)
Returns !(x == y).
void insert(_InputIterator __first, _InputIterator __last)
A template function that tries to insert a range of elements.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
_GLIBCXX_ABI_TAG_CXX11 iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a multiset.
auto equal_range(const _Kt &__x) const -> decltype(_M_t._M_equal_range_tr(__x))
Finds a subsequence matching given key.
size_type size() const noexcept
Returns the size of the set.
iterator insert(const value_type &__x)
Inserts an element into the multiset.
iterator cbegin() const noexcept
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
allocator_type get_allocator() const noexcept
Returns the memory allocation object.
iterator begin() const noexcept
iterator cend() const noexcept
iterator find(const key_type &__x)
Tries to locate an element in a set.
multiset(const allocator_type &__a)
Allocator-extended default constructor.
multiset(multiset &&__x) noexcept(is_nothrow_copy_constructible< _Compare >::value)
Multiset move constructor.
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.