56 #ifndef _STL_MULTISET_H
57 #define _STL_MULTISET_H 1
60 #if __cplusplus >= 201103L
61 #include <initializer_list>
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;
150 const allocator_type& __a = allocator_type())
151 : _M_t(__comp, _Key_alloc_type(__a)) { }
162 template<
typename _InputIterator>
163 multiset(_InputIterator __first, _InputIterator __last)
165 { _M_t._M_insert_equal(__first, __last); }
178 template<
typename _InputIterator>
179 multiset(_InputIterator __first, _InputIterator __last,
180 const _Compare& __comp,
181 const allocator_type& __a = allocator_type())
182 : _M_t(__comp, _Key_alloc_type(__a))
183 { _M_t._M_insert_equal(__first, __last); }
195 #if __cplusplus >= 201103L
204 noexcept(is_nothrow_copy_constructible<_Compare>::value)
205 : _M_t(
std::
move(__x._M_t)) { }
218 const _Compare& __comp = _Compare(),
219 const allocator_type& __a = allocator_type())
220 : _M_t(__comp, _Key_alloc_type(__a))
221 { _M_t._M_insert_equal(__l.begin(), __l.end()); }
226 : _M_t(_Compare(), _Key_alloc_type(__a)) { }
230 : _M_t(__m._M_t, _Key_alloc_type(__a)) { }
234 noexcept(is_nothrow_copy_constructible<_Compare>::value
235 && _Alloc_traits::_S_always_equal())
236 : _M_t(
std::
move(__m._M_t), _Key_alloc_type(__a)) { }
239 multiset(initializer_list<value_type> __l,
const allocator_type& __a)
240 : _M_t(_Compare(), _Key_alloc_type(__a))
241 { _M_t._M_insert_equal(__l.begin(), __l.end()); }
244 template<
typename _InputIterator>
245 multiset(_InputIterator __first, _InputIterator __last,
246 const allocator_type& __a)
247 : _M_t(_Compare(), _Key_alloc_type(__a))
248 { _M_t._M_insert_equal(__first, __last); }
265 #if __cplusplus >= 201103L
284 _M_t._M_assign_equal(__l.begin(), __l.end());
294 {
return _M_t.key_comp(); }
298 {
return _M_t.key_comp(); }
302 {
return allocator_type(_M_t.get_allocator()); }
311 {
return _M_t.begin(); }
319 end() const _GLIBCXX_NOEXCEPT
320 {
return _M_t.end(); }
329 {
return _M_t.rbegin(); }
338 {
return _M_t.rend(); }
340 #if __cplusplus >= 201103L
348 {
return _M_t.begin(); }
357 {
return _M_t.end(); }
366 {
return _M_t.rbegin(); }
375 {
return _M_t.rend(); }
381 {
return _M_t.empty(); }
386 {
return _M_t.size(); }
391 {
return _M_t.max_size(); }
406 #if __cplusplus >= 201103L
407 noexcept(_Alloc_traits::_S_nothrow_swap())
409 { _M_t.swap(__x._M_t); }
412 #if __cplusplus >= 201103L
425 template<
typename... _Args>
428 {
return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); }
451 template<
typename... _Args>
455 return _M_t._M_emplace_hint_equal(__pos,
456 std::forward<_Args>(__args)...);
473 {
return _M_t._M_insert_equal(__x); }
475 #if __cplusplus >= 201103L
478 {
return _M_t._M_insert_equal(
std::move(__x)); }
502 insert(const_iterator __position,
const value_type& __x)
503 {
return _M_t._M_insert_equal_(__position, __x); }
505 #if __cplusplus >= 201103L
507 insert(const_iterator __position, value_type&& __x)
508 {
return _M_t._M_insert_equal_(__position,
std::move(__x)); }
519 template<
typename _InputIterator>
521 insert(_InputIterator __first, _InputIterator __last)
522 { _M_t._M_insert_equal(__first, __last); }
524 #if __cplusplus >= 201103L
534 { this->
insert(__l.begin(), __l.end()); }
537 #if __cplusplus >= 201103L
553 _GLIBCXX_ABI_TAG_CXX11
556 {
return _M_t.erase(__position); }
569 erase(iterator __position)
570 { _M_t.erase(__position); }
586 {
return _M_t.erase(__x); }
588 #if __cplusplus >= 201103L
605 _GLIBCXX_ABI_TAG_CXX11
607 erase(const_iterator __first, const_iterator __last)
608 {
return _M_t.erase(__first, __last); }
623 erase(iterator __first, iterator __last)
624 { _M_t.erase(__first, __last); }
647 {
return _M_t.count(__x); }
649 #if __cplusplus > 201103L
650 template<
typename _Kt>
652 count(
const _Kt& __x)
const -> decltype(_M_t._M_count_tr(__x))
653 {
return _M_t._M_count_tr(__x); }
673 {
return _M_t.find(__x); }
676 find(
const key_type& __x)
const
677 {
return _M_t.find(__x); }
679 #if __cplusplus > 201103L
680 template<
typename _Kt>
682 find(
const _Kt& __x) -> decltype(_M_t._M_find_tr(__x))
683 {
return _M_t._M_find_tr(__x); }
685 template<
typename _Kt>
687 find(
const _Kt& __x)
const -> decltype(_M_t._M_find_tr(__x))
688 {
return _M_t._M_find_tr(__x); }
706 {
return _M_t.lower_bound(__x); }
710 {
return _M_t.lower_bound(__x); }
712 #if __cplusplus > 201103L
713 template<
typename _Kt>
716 -> decltype(_M_t._M_lower_bound_tr(__x))
717 {
return _M_t._M_lower_bound_tr(__x); }
719 template<
typename _Kt>
722 -> decltype(_M_t._M_lower_bound_tr(__x))
723 {
return _M_t._M_lower_bound_tr(__x); }
736 {
return _M_t.upper_bound(__x); }
740 {
return _M_t.upper_bound(__x); }
742 #if __cplusplus > 201103L
743 template<
typename _Kt>
746 -> decltype(_M_t._M_upper_bound_tr(__x))
747 {
return _M_t._M_upper_bound_tr(__x); }
749 template<
typename _Kt>
752 -> decltype(_M_t._M_upper_bound_tr(__x))
753 {
return _M_t._M_upper_bound_tr(__x); }
775 {
return _M_t.equal_range(__x); }
779 {
return _M_t.equal_range(__x); }
781 #if __cplusplus > 201103L
782 template<
typename _Kt>
785 -> decltype(_M_t._M_equal_range_tr(__x))
786 {
return _M_t._M_equal_range_tr(__x); }
788 template<
typename _Kt>
791 -> decltype(_M_t._M_equal_range_tr(__x))
792 {
return _M_t._M_equal_range_tr(__x); }
796 template<
typename _K1,
typename _C1,
typename _A1>
798 operator==(
const multiset<_K1, _C1, _A1>&,
799 const multiset<_K1, _C1, _A1>&);
801 template<
typename _K1,
typename _C1,
typename _A1>
803 operator< (const multiset<_K1, _C1, _A1>&,
804 const multiset<_K1, _C1, _A1>&);
818 template<
typename _Key,
typename _Compare,
typename _Alloc>
822 {
return __x._M_t == __y._M_t; }
835 template<
typename _Key,
typename _Compare,
typename _Alloc>
837 operator<(const multiset<_Key, _Compare, _Alloc>& __x,
839 {
return __x._M_t < __y._M_t; }
842 template<
typename _Key,
typename _Compare,
typename _Alloc>
846 {
return !(__x == __y); }
849 template<
typename _Key,
typename _Compare,
typename _Alloc>
853 {
return __y < __x; }
856 template<
typename _Key,
typename _Compare,
typename _Alloc>
858 operator<=(const multiset<_Key, _Compare, _Alloc>& __x,
860 {
return !(__y < __x); }
863 template<
typename _Key,
typename _Compare,
typename _Alloc>
867 {
return !(__x < __y); }
870 template<
typename _Key,
typename _Compare,
typename _Alloc>
876 _GLIBCXX_END_NAMESPACE_CONTAINER
void swap(_Tp &, _Tp &) noexcept(__and_< is_nothrow_move_constructible< _Tp >, is_nothrow_move_assignable< _Tp >>::value)
Swaps two values.
value_compare value_comp() const
Returns the comparison object.
multiset(initializer_list< value_type > __l, const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())
Builds a multiset from an initializer_list.
multiset(_InputIterator __first, _InputIterator __last, const allocator_type &__a)
Allocator-extended range constructor.
iterator cbegin() const noexcept
multiset(const allocator_type &__a)
Allocator-extended default constructor.
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
bool empty() const noexcept
Returns true if the set is empty.
multiset & operator=(initializer_list< value_type > __l)
Multiset list assignment operator.
iterator emplace_hint(const_iterator __pos, _Args &&...__args)
Builds and inserts an element into the multiset.
void insert(_InputIterator __first, _InputIterator __last)
A template function that tries to insert a range of elements.
Uniform interface to C++98 and C++0x allocators.
multiset(const multiset &__m, const allocator_type &__a)
Allocator-extended copy constructor.
bool operator>=(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string doesn't precede string.
multiset & operator=(const multiset &__x)
Multiset assignment operator.
multiset(_InputIterator __first, _InputIterator __last)
Builds a multiset from a range.
iterator end() const noexcept
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
multiset()
Default constructor creates no elements.
key_compare key_comp() const
Returns the comparison object.
iterator find(const key_type &__x)
Tries to locate an element in a set.
allocator_type get_allocator() const noexcept
Returns the memory allocation object.
iterator cend() const noexcept
multiset(initializer_list< value_type > __l, const allocator_type &__a)
Allocator-extended initialier-list constructor.
multiset(const multiset &__x)
Multiset copy 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.
reverse_iterator rbegin() const noexcept
bool operator>(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string follows string.
iterator begin() const noexcept
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
size_type max_size() const noexcept
Returns the maximum size of the set.
size_type size() const noexcept
Returns the size of the set.
_GLIBCXX_ABI_TAG_CXX11 iterator erase(const_iterator __position)
Erases an element from a multiset.
iterator insert(const value_type &__x)
Inserts an element into the multiset.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
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.
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.
reverse_iterator rend() const noexcept
multiset(multiset &&__x) noexcept(is_nothrow_copy_constructible< _Compare >::value)
Multiset move constructor.
reverse_iterator crend() const noexcept
const_iterator lower_bound(const key_type &__x) const
Finds the beginning 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.
iterator emplace(_Args &&...__args)
Builds and inserts an element into the multiset.
Struct holding two objects of arbitrary type.
size_type count(const key_type &__x) const
Finds the number of elements with given key.
const_iterator find(const key_type &__x) const
Tries to locate an element in a set.
_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.
reverse_iterator crbegin() const noexcept
ISO C++ entities toplevel namespace is std.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.