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)
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 #if __cplusplus >= 201103L 410 noexcept(_Alloc_traits::_S_nothrow_swap())
412 { _M_t.swap(__x._M_t); }
415 #if __cplusplus >= 201103L 428 template<
typename... _Args>
431 {
return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); }
454 template<
typename... _Args>
458 return _M_t._M_emplace_hint_equal(__pos,
459 std::forward<_Args>(__args)...);
476 {
return _M_t._M_insert_equal(__x); }
478 #if __cplusplus >= 201103L 481 {
return _M_t._M_insert_equal(std::move(__x)); }
505 insert(const_iterator __position,
const value_type& __x)
506 {
return _M_t._M_insert_equal_(__position, __x); }
508 #if __cplusplus >= 201103L 510 insert(const_iterator __position, value_type&& __x)
511 {
return _M_t._M_insert_equal_(__position, std::move(__x)); }
522 template<
typename _InputIterator>
524 insert(_InputIterator __first, _InputIterator __last)
525 { _M_t._M_insert_equal(__first, __last); }
527 #if __cplusplus >= 201103L 537 { this->
insert(__l.begin(), __l.end()); }
540 #if __cplusplus >= 201103L 556 _GLIBCXX_ABI_TAG_CXX11
559 {
return _M_t.erase(__position); }
572 erase(iterator __position)
573 { _M_t.erase(__position); }
589 {
return _M_t.erase(__x); }
591 #if __cplusplus >= 201103L 608 _GLIBCXX_ABI_TAG_CXX11
610 erase(const_iterator __first, const_iterator __last)
611 {
return _M_t.erase(__first, __last); }
626 erase(iterator __first, iterator __last)
627 { _M_t.erase(__first, __last); }
650 {
return _M_t.count(__x); }
652 #if __cplusplus > 201103L 653 template<
typename _Kt>
655 count(
const _Kt& __x)
const -> decltype(_M_t._M_count_tr(__x))
656 {
return _M_t._M_count_tr(__x); }
676 {
return _M_t.find(__x); }
679 find(
const key_type& __x)
const 680 {
return _M_t.find(__x); }
682 #if __cplusplus > 201103L 683 template<
typename _Kt>
686 -> decltype(iterator{_M_t._M_find_tr(__x)})
687 {
return iterator{_M_t._M_find_tr(__x)}; }
689 template<
typename _Kt>
692 -> decltype(const_iterator{_M_t._M_find_tr(__x)})
693 {
return const_iterator{_M_t._M_find_tr(__x)}; }
711 {
return _M_t.lower_bound(__x); }
715 {
return _M_t.lower_bound(__x); }
717 #if __cplusplus > 201103L 718 template<
typename _Kt>
721 -> decltype(_M_t._M_lower_bound_tr(__x))
722 {
return _M_t._M_lower_bound_tr(__x); }
724 template<
typename _Kt>
727 -> decltype(_M_t._M_lower_bound_tr(__x))
728 {
return _M_t._M_lower_bound_tr(__x); }
741 {
return _M_t.upper_bound(__x); }
745 {
return _M_t.upper_bound(__x); }
747 #if __cplusplus > 201103L 748 template<
typename _Kt>
751 -> decltype(_M_t._M_upper_bound_tr(__x))
752 {
return _M_t._M_upper_bound_tr(__x); }
754 template<
typename _Kt>
757 -> decltype(_M_t._M_upper_bound_tr(__x))
758 {
return _M_t._M_upper_bound_tr(__x); }
780 {
return _M_t.equal_range(__x); }
784 {
return _M_t.equal_range(__x); }
786 #if __cplusplus > 201103L 787 template<
typename _Kt>
790 -> decltype(_M_t._M_equal_range_tr(__x))
791 {
return _M_t._M_equal_range_tr(__x); }
793 template<
typename _Kt>
796 -> decltype(_M_t._M_equal_range_tr(__x))
797 {
return _M_t._M_equal_range_tr(__x); }
801 template<
typename _K1,
typename _C1,
typename _A1>
806 template<
typename _K1,
typename _C1,
typename _A1>
808 operator< (const multiset<_K1, _C1, _A1>&,
823 template<
typename _Key,
typename _Compare,
typename _Alloc>
827 {
return __x._M_t == __y._M_t; }
840 template<
typename _Key,
typename _Compare,
typename _Alloc>
842 operator<(const multiset<_Key, _Compare, _Alloc>& __x,
844 {
return __x._M_t < __y._M_t; }
847 template<
typename _Key,
typename _Compare,
typename _Alloc>
851 {
return !(__x == __y); }
854 template<
typename _Key,
typename _Compare,
typename _Alloc>
858 {
return __y < __x; }
861 template<
typename _Key,
typename _Compare,
typename _Alloc>
863 operator<=(const multiset<_Key, _Compare, _Alloc>& __x,
865 {
return !(__y < __x); }
868 template<
typename _Key,
typename _Compare,
typename _Alloc>
872 {
return !(__x < __y); }
875 template<
typename _Key,
typename _Compare,
typename _Alloc>
881 _GLIBCXX_END_NAMESPACE_CONTAINER
iterator find(const key_type &__x)
Tries to locate an element in a set.
bool empty() const noexcept
Returns true if the set is empty.
multiset & operator=(const multiset &__x)
Multiset assignment operator.
key_compare key_comp() const
Returns the comparison object.
iterator emplace(_Args &&...__args)
Builds and inserts an element into the multiset.
const_iterator find(const key_type &__x) const
Tries to locate an element in a set.
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
auto find(const _Kt &__x) const -> decltype(const_iterator
Tries to locate an element in a set.
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
size_type count(const key_type &__x) const
Finds the number of elements with given key.
_GLIBCXX_ABI_TAG_CXX11 iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a multiset.
multiset(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a multiset with no elements.
auto find(const _Kt &__x) -> decltype(iterator
Tries to locate an element in a set.
multiset() noexcept(is_nothrow_default_constructible< allocator_type >::value)
Default constructor creates no elements.
size_type size() const noexcept
Returns the size of the set.
void swap(multiset &__x) noexcept(_Alloc_traits::_S_nothrow_swap())
Swaps data with another multiset.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the multiset.
multiset(const multiset &__m, const allocator_type &__a)
Allocator-extended copy constructor.
value_compare value_comp() const
Returns the comparison object.
iterator end() const noexcept
multiset(const allocator_type &__a)
Allocator-extended default constructor.
reverse_iterator rend() const noexcept
size_type erase(const key_type &__x)
Erases elements according to the provided key.
iterator emplace_hint(const_iterator __pos, _Args &&...__args)
Builds and inserts an element into the multiset.
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.
reverse_iterator rbegin() const noexcept
size_type max_size() const noexcept
Returns the maximum size of the set.
reverse_iterator crbegin() 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.
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
allocator_type get_allocator() const noexcept
Returns the memory allocation object.
multiset(multiset &&__m, const allocator_type &__a) noexcept(is_nothrow_copy_constructible< _Compare >::value &&_Alloc_traits::_S_always_equal())
Allocator-extended move constructor.
iterator cend() const noexcept
_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.
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 insert(const_iterator __position, const value_type &__x)
Inserts an element into the multiset.
multiset & operator=(initializer_list< value_type > __l)
Multiset list assignment operator.
auto count(const _Kt &__x) const -> decltype(_M_t._M_count_tr(__x))
Finds the number of elements with given key.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
void insert(_InputIterator __first, _InputIterator __last)
A template function that tries to insert a range of elements.
A standard container made up of elements, which can be retrieved in logarithmic time.
auto equal_range(const _Kt &__x) -> decltype(_M_t._M_equal_range_tr(__x))
Finds a subsequence matching given key.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
Struct holding two objects of arbitrary type.
auto lower_bound(const _Kt &__x) -> decltype(_M_t._M_lower_bound_tr(__x))
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(_InputIterator __first, _InputIterator __last, const allocator_type &__a)
Allocator-extended range constructor.
multiset(multiset &&__x) noexcept(is_nothrow_copy_constructible< _Compare >::value)
Multiset move constructor.
reverse_iterator crend() const noexcept
ISO C++ entities toplevel namespace is std.
multiset(const multiset &__x)
Multiset copy constructor.
Uniform interface to C++98 and C++0x allocators.
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
iterator cbegin() const noexcept
auto equal_range(const _Kt &__x) const -> decltype(_M_t._M_equal_range_tr(__x))
Finds a subsequence matching given key.
iterator insert(const value_type &__x)
Inserts an element into the multiset.
iterator begin() const noexcept
multiset(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a multiset from a range.