57 #ifndef _STL_MULTISET_H
58 #define _STL_MULTISET_H 1
61 #ifdef __GXX_EXPERIMENTAL_CXX0X__
65 namespace std _GLIBCXX_VISIBILITY(default)
67 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
86 template <
typename _Key,
typename _Compare = std::less<_Key>,
87 typename _Alloc = std::allocator<_Key> >
91 typedef typename _Alloc::value_type _Alloc_value_type;
92 __glibcxx_class_requires(_Key, _SGIAssignableConcept)
93 __glibcxx_class_requires4(_Compare,
bool, _Key, _Key,
94 _BinaryFunctionConcept)
95 __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
99 typedef _Key key_type;
100 typedef _Key value_type;
101 typedef _Compare key_compare;
102 typedef _Compare value_compare;
103 typedef _Alloc allocator_type;
107 typedef typename _Alloc::template rebind<_Key>::other _Key_alloc_type;
109 typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
110 key_compare, _Key_alloc_type> _Rep_type;
115 typedef typename _Key_alloc_type::pointer pointer;
116 typedef typename _Key_alloc_type::const_pointer const_pointer;
117 typedef typename _Key_alloc_type::reference reference;
118 typedef typename _Key_alloc_type::const_reference const_reference;
122 typedef typename _Rep_type::const_iterator iterator;
123 typedef typename _Rep_type::const_iterator const_iterator;
126 typedef typename _Rep_type::size_type size_type;
127 typedef typename _Rep_type::difference_type difference_type;
143 const allocator_type& __a = allocator_type())
144 : _M_t(__comp, _Key_alloc_type(__a)) { }
155 template<
typename _InputIterator>
156 multiset(_InputIterator __first, _InputIterator __last)
158 { _M_t._M_insert_equal(__first, __last); }
171 template<
typename _InputIterator>
172 multiset(_InputIterator __first, _InputIterator __last,
173 const _Compare& __comp,
174 const allocator_type& __a = allocator_type())
175 : _M_t(__comp, _Key_alloc_type(__a))
176 { _M_t._M_insert_equal(__first, __last); }
188 #ifdef __GXX_EXPERIMENTAL_CXX0X__
198 : _M_t(std::move(__x._M_t)) { }
211 const _Compare& __comp = _Compare(),
212 const allocator_type& __a = allocator_type())
213 : _M_t(__comp, _Key_alloc_type(__a))
214 { _M_t._M_insert_equal(__l.begin(), __l.end()); }
231 #ifdef __GXX_EXPERIMENTAL_CXX0X__
265 this->
insert(__l.begin(), __l.end());
275 {
return _M_t.key_comp(); }
279 {
return _M_t.key_comp(); }
283 {
return allocator_type(_M_t.get_allocator()); }
292 {
return _M_t.begin(); }
300 end() const _GLIBCXX_NOEXCEPT
301 {
return _M_t.end(); }
310 {
return _M_t.rbegin(); }
319 {
return _M_t.rend(); }
321 #ifdef __GXX_EXPERIMENTAL_CXX0X__
329 {
return _M_t.begin(); }
338 {
return _M_t.end(); }
347 {
return _M_t.rbegin(); }
356 {
return _M_t.rend(); }
362 {
return _M_t.empty(); }
367 {
return _M_t.size(); }
372 {
return _M_t.max_size(); }
387 { _M_t.swap(__x._M_t); }
403 {
return _M_t._M_insert_equal(__x); }
405 #ifdef __GXX_EXPERIMENTAL_CXX0X__
408 {
return _M_t._M_insert_equal(std::move(__x)); }
432 insert(const_iterator __position,
const value_type& __x)
433 {
return _M_t._M_insert_equal_(__position, __x); }
435 #ifdef __GXX_EXPERIMENTAL_CXX0X__
437 insert(const_iterator __position, value_type&& __x)
438 {
return _M_t._M_insert_equal_(__position, std::move(__x)); }
449 template<
typename _InputIterator>
451 insert(_InputIterator __first, _InputIterator __last)
452 { _M_t._M_insert_equal(__first, __last); }
454 #ifdef __GXX_EXPERIMENTAL_CXX0X__
464 { this->
insert(__l.begin(), __l.end()); }
467 #ifdef __GXX_EXPERIMENTAL_CXX0X__
485 {
return _M_t.erase(__position); }
499 { _M_t.erase(__position); }
515 {
return _M_t.erase(__x); }
517 #ifdef __GXX_EXPERIMENTAL_CXX0X__
535 erase(const_iterator __first, const_iterator __last)
536 {
return _M_t.erase(__first, __last); }
552 { _M_t.erase(__first, __last); }
574 {
return _M_t.count(__x); }
592 {
return _M_t.find(__x); }
595 find(
const key_type& __x)
const
596 {
return _M_t.find(__x); }
613 {
return _M_t.lower_bound(__x); }
617 {
return _M_t.lower_bound(__x); }
629 {
return _M_t.upper_bound(__x); }
633 {
return _M_t.upper_bound(__x); }
654 {
return _M_t.equal_range(__x); }
658 {
return _M_t.equal_range(__x); }
661 template<
typename _K1,
typename _C1,
typename _A1>
666 template<
typename _K1,
typename _C1,
typename _A1>
668 operator< (const multiset<_K1, _C1, _A1>&,
683 template<
typename _Key,
typename _Compare,
typename _Alloc>
687 {
return __x._M_t == __y._M_t; }
700 template<
typename _Key,
typename _Compare,
typename _Alloc>
702 operator<(const multiset<_Key, _Compare, _Alloc>& __x,
704 {
return __x._M_t < __y._M_t; }
707 template<
typename _Key,
typename _Compare,
typename _Alloc>
711 {
return !(__x == __y); }
714 template<
typename _Key,
typename _Compare,
typename _Alloc>
718 {
return __y < __x; }
721 template<
typename _Key,
typename _Compare,
typename _Alloc>
723 operator<=(const multiset<_Key, _Compare, _Alloc>& __x,
725 {
return !(__y < __x); }
728 template<
typename _Key,
typename _Compare,
typename _Alloc>
732 {
return !(__x < __y); }
735 template<
typename _Key,
typename _Compare,
typename _Alloc>
741 _GLIBCXX_END_NAMESPACE_CONTAINER
bool empty() const _GLIBCXX_NOEXCEPT
Returns true if the set is empty.
iterator cend() const noexcept
size_type max_size() const _GLIBCXX_NOEXCEPT
Returns the maximum size of the set.
void swap(multiset &__x)
Swaps data with another multiset.
reverse_iterator crbegin() const noexcept
iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a multiset.
iterator begin() const _GLIBCXX_NOEXCEPT
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.
iterator insert(const value_type &__x)
Inserts an element into the multiset.
key_compare key_comp() const
Returns the comparison object.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
allocator_type get_allocator() const _GLIBCXX_NOEXCEPT
Returns the memory allocation object.
const_iterator find(const key_type &__x) const
Tries to locate an element in a set.
multiset(const multiset &__x)
Multiset copy constructor.
multiset & operator=(initializer_list< value_type > __l)
Multiset list assignment operator.
reverse_iterator rbegin() const _GLIBCXX_NOEXCEPT
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the multiset.
iterator erase(const_iterator __position)
Erases an element from a multiset.
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
value_compare value_comp() const
Returns the comparison object.
multiset(multiset &&__x) noexcept(is_nothrow_copy_constructible< _Compare >::value)
Multiset move constructor.
multiset()
Default constructor creates no elements.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
multiset(initializer_list< value_type > __l, const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())
Builds a multiset from an initializer_list.
reverse_iterator crend() const noexcept
iterator insert(const_iterator __position, const value_type &__x)
Inserts an element into the multiset.
multiset(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a multiset with no elements.
reverse_iterator rend() const _GLIBCXX_NOEXCEPT
A standard container made up of elements, which can be retrieved in logarithmic time.
Struct holding two objects of arbitrary type.
multiset & operator=(multiset &&__x)
Multiset move assignment operator.
multiset(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a multiset from a range.
size_type size() const _GLIBCXX_NOEXCEPT
Returns the size of the set.
multiset(_InputIterator __first, _InputIterator __last)
Builds a multiset from a range.
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
void clear() _GLIBCXX_NOEXCEPT
iterator find(const key_type &__x)
Tries to locate an element in a set.
is_nothrow_copy_constructible
multiset & operator=(const multiset &__x)
Multiset assignment operator.
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.
iterator end() const _GLIBCXX_NOEXCEPT
iterator cbegin() const noexcept