57 #ifndef _STL_MULTISET_H
58 #define _STL_MULTISET_H 1
61 #include <initializer_list>
63 _GLIBCXX_BEGIN_NESTED_NAMESPACE(
std, _GLIBCXX_STD_D)
82 template <typename _Key, typename _Compare =
std::less<_Key>,
83 typename _Alloc =
std::allocator<_Key> >
87 typedef typename _Alloc::value_type _Alloc_value_type;
88 __glibcxx_class_requires(_Key, _SGIAssignableConcept)
89 __glibcxx_class_requires4(_Compare,
bool, _Key, _Key,
90 _BinaryFunctionConcept)
91 __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
95 typedef _Key key_type;
96 typedef _Key value_type;
97 typedef _Compare key_compare;
98 typedef _Compare value_compare;
99 typedef _Alloc allocator_type;
103 typedef typename _Alloc::template rebind<_Key>::other _Key_alloc_type;
105 typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
106 key_compare, _Key_alloc_type> _Rep_type;
111 typedef typename _Key_alloc_type::pointer pointer;
112 typedef typename _Key_alloc_type::const_pointer const_pointer;
113 typedef typename _Key_alloc_type::reference reference;
114 typedef typename _Key_alloc_type::const_reference const_reference;
118 typedef typename _Rep_type::const_iterator iterator;
119 typedef typename _Rep_type::const_iterator const_iterator;
122 typedef typename _Rep_type::size_type size_type;
123 typedef typename _Rep_type::difference_type difference_type;
139 const allocator_type& __a = allocator_type())
140 : _M_t(__comp, __a) { }
151 template<
typename _InputIterator>
152 multiset(_InputIterator __first, _InputIterator __last)
154 { _M_t._M_insert_equal(__first, __last); }
167 template<
typename _InputIterator>
168 multiset(_InputIterator __first, _InputIterator __last,
169 const _Compare& __comp,
170 const allocator_type& __a = allocator_type())
172 { _M_t._M_insert_equal(__first, __last); }
184 #ifdef __GXX_EXPERIMENTAL_CXX0X__
193 : _M_t(
std::forward<_Rep_type>(__x._M_t)) { }
206 const _Compare& __comp = _Compare(),
207 const allocator_type& __a = allocator_type())
209 { _M_t._M_insert_equal(__l.begin(), __l.end()); }
226 #ifdef __GXX_EXPERIMENTAL_CXX0X__
258 this->insert(__l.begin(), __l.end());
268 {
return _M_t.key_comp(); }
272 {
return _M_t.key_comp(); }
276 {
return _M_t.get_allocator(); }
285 {
return _M_t.begin(); }
294 {
return _M_t.end(); }
303 {
return _M_t.rbegin(); }
312 {
return _M_t.rend(); }
314 #ifdef __GXX_EXPERIMENTAL_CXX0X__
322 {
return _M_t.begin(); }
331 {
return _M_t.end(); }
340 {
return _M_t.rbegin(); }
349 {
return _M_t.rend(); }
355 {
return _M_t.empty(); }
360 {
return _M_t.size(); }
365 {
return _M_t.max_size(); }
379 #ifdef __GXX_EXPERIMENTAL_CXX0X__
384 { _M_t.swap(__x._M_t); }
400 {
return _M_t._M_insert_equal(__x); }
423 insert(iterator __position,
const value_type& __x)
424 {
return _M_t._M_insert_equal_(__position, __x); }
434 template<
typename _InputIterator>
436 insert(_InputIterator __first, _InputIterator __last)
437 { _M_t._M_insert_equal(__first, __last); }
439 #ifdef __GXX_EXPERIMENTAL_CXX0X__
449 { this->insert(__l.begin(), __l.end()); }
464 { _M_t.erase(__position); }
479 {
return _M_t.erase(__x); }
493 erase(iterator __first, iterator __last)
494 { _M_t.erase(__first, __last); }
515 {
return _M_t.count(__x); }
533 {
return _M_t.find(__x); }
536 find(
const key_type& __x)
const
537 {
return _M_t.find(__x); }
554 {
return _M_t.lower_bound(__x); }
558 {
return _M_t.lower_bound(__x); }
570 {
return _M_t.upper_bound(__x); }
574 {
return _M_t.upper_bound(__x); }
595 {
return _M_t.equal_range(__x); }
599 {
return _M_t.equal_range(__x); }
601 template<
typename _K1,
typename _C1,
typename _A1>
606 template<
typename _K1,
typename _C1,
typename _A1>
608 operator< (const multiset<_K1, _C1, _A1>&,
623 template<
typename _Key,
typename _Compare,
typename _Alloc>
627 {
return __x._M_t == __y._M_t; }
640 template<
typename _Key,
typename _Compare,
typename _Alloc>
642 operator<(const multiset<_Key, _Compare, _Alloc>& __x,
644 {
return __x._M_t < __y._M_t; }
647 template<
typename _Key,
typename _Compare,
typename _Alloc>
651 {
return !(__x == __y); }
654 template<
typename _Key,
typename _Compare,
typename _Alloc>
658 {
return __y < __x; }
661 template<
typename _Key,
typename _Compare,
typename _Alloc>
663 operator<=(const multiset<_Key, _Compare, _Alloc>& __x,
665 {
return !(__y < __x); }
668 template<
typename _Key,
typename _Compare,
typename _Alloc>
672 {
return !(__x < __y); }
675 template<
typename _Key,
typename _Compare,
typename _Alloc>
681 #ifdef __GXX_EXPERIMENTAL_CXX0X__
682 template<
typename _Key,
typename _Compare,
typename _Alloc>
684 swap(multiset<_Key, _Compare, _Alloc>&& __x,
685 multiset<_Key, _Compare, _Alloc>& __y)
688 template<
typename _Key,
typename _Compare,
typename _Alloc>
690 swap(multiset<_Key, _Compare, _Alloc>& __x,
691 multiset<_Key, _Compare, _Alloc>&& __y)
695 _GLIBCXX_END_NESTED_NAMESPACE
bool empty() const
Returns true if the set is empty.
multiset(_InputIterator __first, _InputIterator __last)
Builds a multiset from a range.
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
void erase(iterator __position)
Erases an element from a multiset.
bool operator>=(const multiset< _Key, _Compare, _Alloc > &__x, const multiset< _Key, _Compare, _Alloc > &__y)
Returns !(x < y)
bool operator!=(const multiset< _Key, _Compare, _Alloc > &__x, const multiset< _Key, _Compare, _Alloc > &__y)
Returns !(x == y).
iterator insert(iterator __position, const value_type &__x)
Inserts an element into the multiset.
bool operator>(const multiset< _Key, _Compare, _Alloc > &__x, const multiset< _Key, _Compare, _Alloc > &__y)
Returns y < x.
const_iterator find(const key_type &__x) const
Tries to locate an element in a set.
ISO C++ entities toplevel namespace is std.
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
multiset & operator=(const multiset &__x)
Multiset assignment operator.
multiset(const multiset &__x)
Multiset copy constructor.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
pair holds two objects of arbitrary type.
void erase(iterator __first, iterator __last)
Erases a [first,last) range of elements from a multiset.
size_type max_size() const
Returns the maximum size of the set.
size_type size() const
Returns the size of the set.
multiset(multiset &&__x)
Multiset move constructor.
reverse_iterator crbegin() const
key_compare key_comp() const
Returns the comparison object.
void insert(_InputIterator __first, _InputIterator __last)
A template function that attempts to insert a range of elements.
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.
multiset(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a multiset with no elements.
multiset & operator=(multiset &&__x)
Multiset move assignment operator.
allocator_type get_allocator() const
Returns the memory allocation object.
size_type count(const key_type &__x) const
Finds the number of elements with given key.
reverse_iterator rend() const
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the multiset.
iterator find(const key_type &__x)
Tries to locate an element in a set.
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 rbegin() const
void swap(multiset &&__x)
Swaps data with another multiset.
reverse_iterator crend() const
bool operator==(const multiset< _Key, _Compare, _Alloc > &__x, const multiset< _Key, _Compare, _Alloc > &__y)
Multiset equality comparison.
multiset(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a multiset from a range.
multiset()
Default constructor creates no elements.
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
multiset & operator=(initializer_list< value_type > __l)
Multiset list assignment operator.
value_compare value_comp() const
Returns the comparison object.
iterator insert(const value_type &__x)
Inserts an element into the multiset.