57 #ifndef _STL_MULTIMAP_H
58 #define _STL_MULTIMAP_H 1
61 #include <initializer_list>
63 _GLIBCXX_BEGIN_NESTED_NAMESPACE(
std, _GLIBCXX_STD_D)
83 template <typename _Key, typename _Tp,
84 typename _Compare =
std::less<_Key>,
85 typename _Alloc =
std::allocator<
std::pair<const _Key, _Tp> > >
89 typedef _Key key_type;
90 typedef _Tp mapped_type;
92 typedef _Compare key_compare;
93 typedef _Alloc allocator_type;
97 typedef typename _Alloc::value_type _Alloc_value_type;
98 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
99 __glibcxx_class_requires4(_Compare,
bool, _Key, _Key,
100 _BinaryFunctionConcept)
101 __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept)
107 friend class multimap<_Key, _Tp, _Compare, _Alloc>;
111 value_compare(_Compare __c)
115 bool operator()(
const value_type& __x,
const value_type& __y)
const
121 typedef typename _Alloc::template rebind<value_type>::other
124 typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
125 key_compare, _Pair_alloc_type> _Rep_type;
132 typedef typename _Pair_alloc_type::pointer pointer;
133 typedef typename _Pair_alloc_type::const_pointer const_pointer;
134 typedef typename _Pair_alloc_type::reference reference;
135 typedef typename _Pair_alloc_type::const_reference const_reference;
136 typedef typename _Rep_type::iterator iterator;
137 typedef typename _Rep_type::const_iterator const_iterator;
138 typedef typename _Rep_type::size_type size_type;
139 typedef typename _Rep_type::difference_type difference_type;
158 const allocator_type& __a = allocator_type())
159 : _M_t(__comp, __a) { }
171 #ifdef __GXX_EXPERIMENTAL_CXX0X__
180 : _M_t(
std::forward<_Rep_type>(__x._M_t)) { }
193 const _Compare& __comp = _Compare(),
194 const allocator_type& __a = allocator_type())
196 { _M_t._M_insert_equal(__l.begin(), __l.end()); }
208 template<
typename _InputIterator>
209 multimap(_InputIterator __first, _InputIterator __last)
211 { _M_t._M_insert_equal(__first, __last); }
224 template<
typename _InputIterator>
225 multimap(_InputIterator __first, _InputIterator __last,
226 const _Compare& __comp,
227 const allocator_type& __a = allocator_type())
229 { _M_t._M_insert_equal(__first, __last); }
254 #ifdef __GXX_EXPERIMENTAL_CXX0X__
286 this->insert(__l.begin(), __l.end());
294 {
return _M_t.get_allocator(); }
304 {
return _M_t.begin(); }
313 {
return _M_t.begin(); }
322 {
return _M_t.end(); }
331 {
return _M_t.end(); }
340 {
return _M_t.rbegin(); }
347 const_reverse_iterator
349 {
return _M_t.rbegin(); }
358 {
return _M_t.rend(); }
365 const_reverse_iterator
367 {
return _M_t.rend(); }
369 #ifdef __GXX_EXPERIMENTAL_CXX0X__
377 {
return _M_t.begin(); }
386 {
return _M_t.end(); }
393 const_reverse_iterator
395 {
return _M_t.rbegin(); }
402 const_reverse_iterator
404 {
return _M_t.rend(); }
411 {
return _M_t.empty(); }
416 {
return _M_t.size(); }
421 {
return _M_t.max_size(); }
438 {
return _M_t._M_insert_equal(__x); }
461 insert(iterator __position,
const value_type& __x)
462 {
return _M_t._M_insert_equal_(__position, __x); }
473 template<
typename _InputIterator>
475 insert(_InputIterator __first, _InputIterator __last)
476 { _M_t._M_insert_equal(__first, __last); }
478 #ifdef __GXX_EXPERIMENTAL_CXX0X__
488 { this->insert(__l.begin(), __l.end()); }
503 { _M_t.erase(__position); }
518 {
return _M_t.erase(__x); }
532 erase(iterator __first, iterator __last)
533 { _M_t.erase(__first, __last); }
547 #ifdef __GXX_EXPERIMENTAL_CXX0X__
552 { _M_t.swap(__x._M_t); }
571 {
return _M_t.key_comp(); }
579 {
return value_compare(_M_t.key_comp()); }
595 {
return _M_t.find(__x); }
609 find(
const key_type& __x)
const
610 {
return _M_t.find(__x); }
619 {
return _M_t.count(__x); }
634 {
return _M_t.lower_bound(__x); }
649 {
return _M_t.lower_bound(__x); }
659 {
return _M_t.upper_bound(__x); }
669 {
return _M_t.upper_bound(__x); }
686 {
return _M_t.equal_range(__x); }
703 {
return _M_t.equal_range(__x); }
705 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
710 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
712 operator<(const multimap<_K1, _T1, _C1, _A1>&,
726 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
730 {
return __x._M_t == __y._M_t; }
743 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
745 operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
747 {
return __x._M_t < __y._M_t; }
750 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
754 {
return !(__x == __y); }
757 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
761 {
return __y < __x; }
764 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
766 operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
768 {
return !(__y < __x); }
771 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
775 {
return !(__x < __y); }
778 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
784 #ifdef __GXX_EXPERIMENTAL_CXX0X__
785 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
787 swap(multimap<_Key, _Tp, _Compare, _Alloc>&& __x,
788 multimap<_Key, _Tp, _Compare, _Alloc>& __y)
791 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
793 swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
794 multimap<_Key, _Tp, _Compare, _Alloc>&& __y)
798 _GLIBCXX_END_NESTED_NAMESPACE
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
multimap(const multimap &__x)
Multimap copy constructor.
void erase(iterator __first, iterator __last)
Erases a [first,last) range of elements from a multimap.
bool operator!=(const multimap< _Key, _Tp, _Compare, _Alloc > &__x, const multimap< _Key, _Tp, _Compare, _Alloc > &__y)
Based on operator==.
void insert(_InputIterator __first, _InputIterator __last)
A template function that attempts to insert a range of elements.
size_type max_size() const
const_iterator begin() const
const_iterator end() const
iterator insert(const value_type &__x)
Inserts a std::pair into the multimap.
_T1 first
first is a copy of the first object
multimap & operator=(initializer_list< value_type > __l)
Multimap list assignment operator.
ISO C++ entities toplevel namespace is std.
multimap(multimap &&__x)
Multimap move constructor.
reverse_iterator rbegin()
allocator_type get_allocator() const
Get a copy of the memory allocation object.
bool operator>(const multimap< _Key, _Tp, _Compare, _Alloc > &__x, const multimap< _Key, _Tp, _Compare, _Alloc > &__y)
Based on operator<.
const_iterator cend() const
multimap()
Default constructor creates no elements.
const_reverse_iterator rbegin() const
iterator find(const key_type &__x)
Tries to locate an element in a multimap.
const_iterator find(const key_type &__x) const
Tries to locate an element in a multimap.
multimap & operator=(const multimap &__x)
Multimap assignment operator.
bool operator==(const multimap< _Key, _Tp, _Compare, _Alloc > &__x, const multimap< _Key, _Tp, _Compare, _Alloc > &__y)
Multimap equality comparison.
bool operator>=(const multimap< _Key, _Tp, _Compare, _Alloc > &__x, const multimap< _Key, _Tp, _Compare, _Alloc > &__y)
Based on operator<.
pair holds two objects of arbitrary type.
multimap(initializer_list< value_type > __l, const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())
Builds a multimap from an initializer_list.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
A standard container made up of (key,value) pairs, which can be retrieved based on a key...
size_type count(const key_type &__x) const
Finds the number of elements with given key.
const_reverse_iterator rend() const
void insert(initializer_list< value_type > __l)
Attempts to insert a list of std::pairs into the multimap.
key_compare key_comp() const
multimap(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a multimap with no elements.
iterator insert(iterator __position, const value_type &__x)
Inserts a std::pair into the multimap.
const_iterator cbegin() const
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
void swap(multimap &&__x)
Swaps data with another multimap.
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
const_reverse_iterator crend() const
size_type erase(const key_type &__x)
Erases elements according to the provided key.
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
multimap(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a multimap from a range.
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
void erase(iterator __position)
Erases an element from a multimap.
value_compare value_comp() const
multimap(_InputIterator __first, _InputIterator __last)
Builds a multimap from a range.
const_reverse_iterator crbegin() const
multimap & operator=(multimap &&__x)
Multimap move assignment operator.