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 _GLIBCXX_NOEXCEPT_IF(
142 is_nothrow_default_constructible<allocator_type>::value
143 && is_nothrow_default_constructible<key_compare>::value)
153 const allocator_type& __a = allocator_type())
154 : _M_t(__comp, _Key_alloc_type(__a)) { }
165 template<
typename _InputIterator>
166 multiset(_InputIterator __first, _InputIterator __last)
168 { _M_t._M_insert_equal(__first, __last); }
181 template<
typename _InputIterator>
182 multiset(_InputIterator __first, _InputIterator __last,
183 const _Compare& __comp,
184 const allocator_type& __a = allocator_type())
185 : _M_t(__comp, _Key_alloc_type(__a))
186 { _M_t._M_insert_equal(__first, __last); }
198 #if __cplusplus >= 201103L 207 noexcept(is_nothrow_copy_constructible<_Compare>::value)
208 : _M_t(
std::move(__x._M_t)) { }
221 const _Compare& __comp = _Compare(),
222 const allocator_type& __a = allocator_type())
223 : _M_t(__comp, _Key_alloc_type(__a))
224 { _M_t._M_insert_equal(__l.begin(), __l.end()); }
229 : _M_t(_Compare(), _Key_alloc_type(__a)) { }
233 : _M_t(__m._M_t, _Key_alloc_type(__a)) { }
237 noexcept(is_nothrow_copy_constructible<_Compare>::value
238 && _Alloc_traits::_S_always_equal())
239 : _M_t(
std::move(__m._M_t), _Key_alloc_type(__a)) { }
243 : _M_t(_Compare(), _Key_alloc_type(__a))
244 { _M_t._M_insert_equal(__l.begin(), __l.end()); }
247 template<
typename _InputIterator>
248 multiset(_InputIterator __first, _InputIterator __last,
249 const allocator_type& __a)
250 : _M_t(_Compare(), _Key_alloc_type(__a))
251 { _M_t._M_insert_equal(__first, __last); }
268 #if __cplusplus >= 201103L 287 _M_t._M_assign_equal(__l.begin(), __l.end());
297 {
return _M_t.key_comp(); }
301 {
return _M_t.key_comp(); }
305 {
return allocator_type(_M_t.get_allocator()); }
314 {
return _M_t.begin(); }
322 end() const _GLIBCXX_NOEXCEPT
323 {
return _M_t.end(); }
332 {
return _M_t.rbegin(); }
341 {
return _M_t.rend(); }
343 #if __cplusplus >= 201103L 351 {
return _M_t.begin(); }
360 {
return _M_t.end(); }
369 {
return _M_t.rbegin(); }
378 {
return _M_t.rend(); }
384 {
return _M_t.empty(); }
389 {
return _M_t.size(); }
394 {
return _M_t.max_size(); }
409 _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
410 { _M_t.swap(__x._M_t); }
413 #if __cplusplus >= 201103L 426 template<
typename... _Args>
429 {
return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); }
452 template<
typename... _Args>
456 return _M_t._M_emplace_hint_equal(__pos,
457 std::forward<_Args>(__args)...);
474 {
return _M_t._M_insert_equal(__x); }
476 #if __cplusplus >= 201103L 479 {
return _M_t._M_insert_equal(std::move(__x)); }
503 insert(const_iterator __position,
const value_type& __x)
504 {
return _M_t._M_insert_equal_(__position, __x); }
506 #if __cplusplus >= 201103L 508 insert(const_iterator __position, value_type&& __x)
509 {
return _M_t._M_insert_equal_(__position, std::move(__x)); }
520 template<
typename _InputIterator>
522 insert(_InputIterator __first, _InputIterator __last)
523 { _M_t._M_insert_equal(__first, __last); }
525 #if __cplusplus >= 201103L 535 { this->
insert(__l.begin(), __l.end()); }
538 #if __cplusplus >= 201103L 554 _GLIBCXX_ABI_TAG_CXX11
557 {
return _M_t.erase(__position); }
570 erase(iterator __position)
571 { _M_t.erase(__position); }
587 {
return _M_t.erase(__x); }
589 #if __cplusplus >= 201103L 606 _GLIBCXX_ABI_TAG_CXX11
608 erase(const_iterator __first, const_iterator __last)
609 {
return _M_t.erase(__first, __last); }
624 erase(iterator __first, iterator __last)
625 { _M_t.erase(__first, __last); }
648 {
return _M_t.count(__x); }
650 #if __cplusplus > 201103L 651 template<
typename _Kt>
653 count(
const _Kt& __x)
const -> decltype(_M_t._M_count_tr(__x))
654 {
return _M_t._M_count_tr(__x); }
674 {
return _M_t.find(__x); }
677 find(
const key_type& __x)
const 678 {
return _M_t.find(__x); }
680 #if __cplusplus > 201103L 681 template<
typename _Kt>
684 -> decltype(iterator{_M_t._M_find_tr(__x)})
685 {
return iterator{_M_t._M_find_tr(__x)}; }
687 template<
typename _Kt>
690 -> decltype(const_iterator{_M_t._M_find_tr(__x)})
691 {
return const_iterator{_M_t._M_find_tr(__x)}; }
709 {
return _M_t.lower_bound(__x); }
713 {
return _M_t.lower_bound(__x); }
715 #if __cplusplus > 201103L 716 template<
typename _Kt>
719 -> decltype(_M_t._M_lower_bound_tr(__x))
720 {
return _M_t._M_lower_bound_tr(__x); }
722 template<
typename _Kt>
725 -> decltype(_M_t._M_lower_bound_tr(__x))
726 {
return _M_t._M_lower_bound_tr(__x); }
739 {
return _M_t.upper_bound(__x); }
743 {
return _M_t.upper_bound(__x); }
745 #if __cplusplus > 201103L 746 template<
typename _Kt>
749 -> decltype(_M_t._M_upper_bound_tr(__x))
750 {
return _M_t._M_upper_bound_tr(__x); }
752 template<
typename _Kt>
755 -> decltype(_M_t._M_upper_bound_tr(__x))
756 {
return _M_t._M_upper_bound_tr(__x); }
778 {
return _M_t.equal_range(__x); }
782 {
return _M_t.equal_range(__x); }
784 #if __cplusplus > 201103L 785 template<
typename _Kt>
788 -> decltype(_M_t._M_equal_range_tr(__x))
789 {
return _M_t._M_equal_range_tr(__x); }
791 template<
typename _Kt>
794 -> decltype(_M_t._M_equal_range_tr(__x))
795 {
return _M_t._M_equal_range_tr(__x); }
799 template<
typename _K1,
typename _C1,
typename _A1>
804 template<
typename _K1,
typename _C1,
typename _A1>
806 operator< (const multiset<_K1, _C1, _A1>&,
821 template<
typename _Key,
typename _Compare,
typename _Alloc>
825 {
return __x._M_t == __y._M_t; }
838 template<
typename _Key,
typename _Compare,
typename _Alloc>
840 operator<(const multiset<_Key, _Compare, _Alloc>& __x,
842 {
return __x._M_t < __y._M_t; }
845 template<
typename _Key,
typename _Compare,
typename _Alloc>
849 {
return !(__x == __y); }
852 template<
typename _Key,
typename _Compare,
typename _Alloc>
856 {
return __y < __x; }
859 template<
typename _Key,
typename _Compare,
typename _Alloc>
861 operator<=(const multiset<_Key, _Compare, _Alloc>& __x,
863 {
return !(__y < __x); }
866 template<
typename _Key,
typename _Compare,
typename _Alloc>
870 {
return !(__x < __y); }
873 template<
typename _Key,
typename _Compare,
typename _Alloc>
877 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
880 _GLIBCXX_END_NAMESPACE_CONTAINER
multiset(const allocator_type &__a)
Allocator-extended default constructor.
bool empty() const noexcept
Returns true if the set is empty.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
reverse_iterator crbegin() const noexcept
auto equal_range(const _Kt &__x) const -> decltype(_M_t._M_equal_range_tr(__x))
Finds a subsequence matching given key.
void swap(multiset &__x) noexcept(/*conditional */)
Swaps data with another multiset.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the multiset.
value_compare value_comp() const
Returns the comparison object.
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 end() const noexcept
auto find(const _Kt &__x) -> decltype(iterator
Tries to locate an element in a set.
Uniform interface to C++98 and C++11 allocators.
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(_InputIterator __first, _InputIterator __last)
Builds a multiset from a range.
multiset(_InputIterator __first, _InputIterator __last, const allocator_type &__a)
Allocator-extended range constructor.
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
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.
_GLIBCXX_ABI_TAG_CXX11 iterator erase(const_iterator __position)
Erases an element from a multiset.
multiset(initializer_list< value_type > __l, const allocator_type &__a)
Allocator-extended initialier-list constructor.
iterator emplace_hint(const_iterator __pos, _Args &&...__args)
Builds and inserts an element into the multiset.
iterator emplace(_Args &&...__args)
Builds and inserts an element into the multiset.
multiset(multiset &&__m, const allocator_type &__a) noexcept(is_nothrow_copy_constructible< _Compare >::value &&_Alloc_traits::_S_always_equal())
Allocator-extended move constructor.
size_type max_size() const noexcept
Returns the maximum size of the set.
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
auto lower_bound(const _Kt &__x) -> decltype(_M_t._M_lower_bound_tr(__x))
Finds the beginning of a subsequence matching given key.
iterator insert(const_iterator __position, const value_type &__x)
Inserts an element into the multiset.
const_iterator find(const key_type &__x) const
Tries to locate an element in a set.
multiset(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a multiset from a range.
multiset(multiset &&__x) noexcept(is_nothrow_copy_constructible< _Compare >::value)
Multiset move constructor.
size_type count(const key_type &__x) const
Finds the number of elements with given key.
multiset(const multiset &__x)
Multiset copy constructor.
reverse_iterator rend() const noexcept
multiset & operator=(initializer_list< value_type > __l)
Multiset list assignment operator.
key_compare key_comp() const
Returns the comparison object.
Struct holding two objects of arbitrary type.
auto equal_range(const _Kt &__x) -> decltype(_M_t._M_equal_range_tr(__x))
Finds a subsequence matching given key.
multiset(const multiset &__m, const allocator_type &__a)
Allocator-extended copy constructor.
multiset & operator=(const multiset &__x)
Multiset assignment operator.
iterator begin() const noexcept
size_type size() const noexcept
Returns the size of the set.
auto count(const _Kt &__x) const -> decltype(_M_t._M_count_tr(__x))
Finds the number of elements with given key.
reverse_iterator rbegin() const noexcept
multiset() noexcept(/*conditional */)
Default constructor creates no elements.
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
iterator cbegin() const noexcept
reverse_iterator crend() 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.
multiset(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a multiset with no elements.
iterator find(const key_type &__x)
Tries to locate an element in a set.
iterator cend() const noexcept
auto find(const _Kt &__x) const -> decltype(const_iterator
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 value_type &__x)
Inserts an element into the multiset.
ISO C++ entities toplevel namespace is std.
void insert(_InputIterator __first, _InputIterator __last)
A template function that tries to insert a range of elements.
_GLIBCXX_ABI_TAG_CXX11 iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a multiset.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds 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.