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
90 template <
typename _Key,
typename _Compare = std::less<_Key>,
91 typename _Alloc = std::allocator<_Key> >
95 typedef typename _Alloc::value_type _Alloc_value_type;
96 __glibcxx_class_requires(_Key, _SGIAssignableConcept)
97 __glibcxx_class_requires4(_Compare,
bool, _Key, _Key,
98 _BinaryFunctionConcept)
99 __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
103 typedef _Key key_type;
104 typedef _Key value_type;
105 typedef _Compare key_compare;
106 typedef _Compare value_compare;
107 typedef _Alloc allocator_type;
112 rebind<_Key>::other _Key_alloc_type;
114 typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
115 key_compare, _Key_alloc_type> _Rep_type;
122 typedef typename _Alloc_traits::pointer pointer;
123 typedef typename _Alloc_traits::const_pointer const_pointer;
124 typedef typename _Alloc_traits::reference reference;
125 typedef typename _Alloc_traits::const_reference const_reference;
129 typedef typename _Rep_type::const_iterator iterator;
130 typedef typename _Rep_type::const_iterator const_iterator;
133 typedef typename _Rep_type::size_type size_type;
134 typedef typename _Rep_type::difference_type difference_type;
141 #if __cplusplus >= 201103L 142 noexcept(is_nothrow_default_constructible<allocator_type>::value
143 && is_nothrow_default_constructible<key_compare>::value)
154 const allocator_type& __a = allocator_type())
155 : _M_t(__comp, _Key_alloc_type(__a)) { }
166 template<
typename _InputIterator>
167 multiset(_InputIterator __first, _InputIterator __last)
169 { _M_t._M_insert_equal(__first, __last); }
182 template<
typename _InputIterator>
183 multiset(_InputIterator __first, _InputIterator __last,
184 const _Compare& __comp,
185 const allocator_type& __a = allocator_type())
186 : _M_t(__comp, _Key_alloc_type(__a))
187 { _M_t._M_insert_equal(__first, __last); }
199 #if __cplusplus >= 201103L 208 noexcept(is_nothrow_copy_constructible<_Compare>::value)
209 : _M_t(
std::move(__x._M_t)) { }
222 const _Compare& __comp = _Compare(),
223 const allocator_type& __a = allocator_type())
224 : _M_t(__comp, _Key_alloc_type(__a))
225 { _M_t._M_insert_equal(__l.begin(), __l.end()); }
230 : _M_t(_Compare(), _Key_alloc_type(__a)) { }
234 : _M_t(__m._M_t, _Key_alloc_type(__a)) { }
238 noexcept(is_nothrow_copy_constructible<_Compare>::value
239 && _Alloc_traits::_S_always_equal())
240 : _M_t(
std::move(__m._M_t), _Key_alloc_type(__a)) { }
244 : _M_t(_Compare(), _Key_alloc_type(__a))
245 { _M_t._M_insert_equal(__l.begin(), __l.end()); }
248 template<
typename _InputIterator>
249 multiset(_InputIterator __first, _InputIterator __last,
250 const allocator_type& __a)
251 : _M_t(_Compare(), _Key_alloc_type(__a))
252 { _M_t._M_insert_equal(__first, __last); }
269 #if __cplusplus >= 201103L 288 _M_t._M_assign_equal(__l.begin(), __l.end());
298 {
return _M_t.key_comp(); }
302 {
return _M_t.key_comp(); }
306 {
return allocator_type(_M_t.get_allocator()); }
315 {
return _M_t.begin(); }
323 end() const _GLIBCXX_NOEXCEPT
324 {
return _M_t.end(); }
333 {
return _M_t.rbegin(); }
342 {
return _M_t.rend(); }
344 #if __cplusplus >= 201103L 352 {
return _M_t.begin(); }
361 {
return _M_t.end(); }
370 {
return _M_t.rbegin(); }
379 {
return _M_t.rend(); }
385 {
return _M_t.empty(); }
390 {
return _M_t.size(); }
395 {
return _M_t.max_size(); }
410 #if __cplusplus >= 201103L 411 noexcept(_Alloc_traits::_S_nothrow_swap())
413 { _M_t.swap(__x._M_t); }
416 #if __cplusplus >= 201103L 429 template<
typename... _Args>
432 {
return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); }
455 template<
typename... _Args>
459 return _M_t._M_emplace_hint_equal(__pos,
460 std::forward<_Args>(__args)...);
477 {
return _M_t._M_insert_equal(__x); }
479 #if __cplusplus >= 201103L 482 {
return _M_t._M_insert_equal(std::move(__x)); }
506 insert(const_iterator __position,
const value_type& __x)
507 {
return _M_t._M_insert_equal_(__position, __x); }
509 #if __cplusplus >= 201103L 511 insert(const_iterator __position, value_type&& __x)
512 {
return _M_t._M_insert_equal_(__position, std::move(__x)); }
523 template<
typename _InputIterator>
525 insert(_InputIterator __first, _InputIterator __last)
526 { _M_t._M_insert_equal(__first, __last); }
528 #if __cplusplus >= 201103L 538 { this->
insert(__l.begin(), __l.end()); }
541 #if __cplusplus >= 201103L 557 _GLIBCXX_ABI_TAG_CXX11
560 {
return _M_t.erase(__position); }
573 erase(iterator __position)
574 { _M_t.erase(__position); }
590 {
return _M_t.erase(__x); }
592 #if __cplusplus >= 201103L 609 _GLIBCXX_ABI_TAG_CXX11
611 erase(const_iterator __first, const_iterator __last)
612 {
return _M_t.erase(__first, __last); }
627 erase(iterator __first, iterator __last)
628 { _M_t.erase(__first, __last); }
651 {
return _M_t.count(__x); }
653 #if __cplusplus > 201103L 654 template<
typename _Kt>
656 count(
const _Kt& __x)
const -> decltype(_M_t._M_count_tr(__x))
657 {
return _M_t._M_count_tr(__x); }
677 {
return _M_t.find(__x); }
680 find(
const key_type& __x)
const 681 {
return _M_t.find(__x); }
683 #if __cplusplus > 201103L 684 template<
typename _Kt>
687 -> decltype(iterator{_M_t._M_find_tr(__x)})
688 {
return iterator{_M_t._M_find_tr(__x)}; }
690 template<
typename _Kt>
693 -> decltype(const_iterator{_M_t._M_find_tr(__x)})
694 {
return const_iterator{_M_t._M_find_tr(__x)}; }
712 {
return _M_t.lower_bound(__x); }
716 {
return _M_t.lower_bound(__x); }
718 #if __cplusplus > 201103L 719 template<
typename _Kt>
722 -> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
723 {
return iterator(_M_t._M_lower_bound_tr(__x)); }
725 template<
typename _Kt>
728 -> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
729 {
return iterator(_M_t._M_lower_bound_tr(__x)); }
742 {
return _M_t.upper_bound(__x); }
746 {
return _M_t.upper_bound(__x); }
748 #if __cplusplus > 201103L 749 template<
typename _Kt>
752 -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
753 {
return iterator(_M_t._M_upper_bound_tr(__x)); }
755 template<
typename _Kt>
758 -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
759 {
return iterator(_M_t._M_upper_bound_tr(__x)); }
781 {
return _M_t.equal_range(__x); }
785 {
return _M_t.equal_range(__x); }
787 #if __cplusplus > 201103L 788 template<
typename _Kt>
794 template<
typename _Kt>
802 template<
typename _K1,
typename _C1,
typename _A1>
807 template<
typename _K1,
typename _C1,
typename _A1>
809 operator< (const multiset<_K1, _C1, _A1>&,
824 template<
typename _Key,
typename _Compare,
typename _Alloc>
828 {
return __x._M_t == __y._M_t; }
841 template<
typename _Key,
typename _Compare,
typename _Alloc>
843 operator<(const multiset<_Key, _Compare, _Alloc>& __x,
845 {
return __x._M_t < __y._M_t; }
848 template<
typename _Key,
typename _Compare,
typename _Alloc>
852 {
return !(__x == __y); }
855 template<
typename _Key,
typename _Compare,
typename _Alloc>
859 {
return __y < __x; }
862 template<
typename _Key,
typename _Compare,
typename _Alloc>
864 operator<=(const multiset<_Key, _Compare, _Alloc>& __x,
866 {
return !(__y < __x); }
869 template<
typename _Key,
typename _Compare,
typename _Alloc>
873 {
return !(__x < __y); }
876 template<
typename _Key,
typename _Compare,
typename _Alloc>
882 _GLIBCXX_END_NAMESPACE_CONTAINER
multiset(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a multiset from a range.
iterator emplace_hint(const_iterator __pos, _Args &&... __args)
Builds and inserts an element into the multiset.
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.
auto find(const _Kt &__x) -> decltype(iterator
Tries to locate an element in a set.
size_type size() const noexcept
Returns the size of the set.
multiset(multiset &&__x) noexcept(is_nothrow_copy_constructible< _Compare >::value)
Multiset move constructor.
multiset() noexcept(is_nothrow_default_constructible< allocator_type >::value &&is_nothrow_default_constructible< key_compare >::value)
Default constructor creates no elements.
multiset & operator=(initializer_list< value_type > __l)
Multiset list assignment operator.
size_type max_size() const noexcept
Returns the maximum size of the set.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the multiset.
key_compare key_comp() const
Returns the comparison object.
multiset(const multiset &__x)
Multiset copy constructor.
reverse_iterator crbegin() const noexcept
iterator insert(const value_type &__x)
Inserts an element into the multiset.
multiset(initializer_list< value_type > __l, const allocator_type &__a)
Allocator-extended initialier-list constructor.
multiset(multiset &&__m, const allocator_type &__a) noexcept(is_nothrow_copy_constructible< _Compare >::value &&_Alloc_traits::_S_always_equal())
Allocator-extended move constructor.
multiset(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a multiset with no elements.
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 allocator_type &__a)
Allocator-extended range constructor.
iterator end() const noexcept
multiset & operator=(const multiset &__x)
Multiset assignment operator.
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(const multiset &__m, const allocator_type &__a)
Allocator-extended copy constructor.
iterator cbegin() const noexcept
reverse_iterator crend() const noexcept
A standard container made up of elements, which can be retrieved in logarithmic time.
Uniform interface to C++98 and C++0x allocators.
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 insert(const_iterator __position, const value_type &__x)
Inserts an element into the multiset.
_GLIBCXX_ABI_TAG_CXX11 iterator erase(const_iterator __position)
Erases an element from a multiset.
ISO C++ entities toplevel namespace is std.
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
const_iterator find(const key_type &__x) const
Tries to locate an element in a set.
auto find(const _Kt &__x) const -> decltype(const_iterator
Tries to locate an element in a set.
bool empty() const noexcept
Returns true if the set is empty.
reverse_iterator rend() const noexcept
_GLIBCXX_ABI_TAG_CXX11 iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a multiset.
Struct holding two objects of arbitrary type.
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
auto count(const _Kt &__x) const -> decltype(_M_t._M_count_tr(__x))
Finds the number of elements with given key.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
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.
auto equal_range(const _Kt &__x) const -> decltype(pair< iterator, iterator >(_M_t._M_equal_range_tr(__x)))
Finds a subsequence matching given key.
reverse_iterator rbegin() 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.
iterator emplace(_Args &&... __args)
Builds and inserts an element into the multiset.
value_compare value_comp() const
Returns the comparison object.
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.
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
iterator cend() const noexcept
void swap(multiset &__x) noexcept(_Alloc_traits::_S_nothrow_swap())
Swaps data with another multiset.
multiset(_InputIterator __first, _InputIterator __last)
Builds a multiset from a range.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
multiset(const allocator_type &__a)
Allocator-extended default constructor.
allocator_type get_allocator() const noexcept
Returns the memory allocation object.
iterator find(const key_type &__x)
Tries to locate an element in a set.
size_type count(const key_type &__x) const
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.