56 #ifndef _STL_MULTIMAP_H 57 #define _STL_MULTIMAP_H 1 60 #if __cplusplus >= 201103L 64 namespace std _GLIBCXX_VISIBILITY(default)
66 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
92 template <
typename _Key,
typename _Tp,
98 typedef _Key key_type;
99 typedef _Tp mapped_type;
101 typedef _Compare key_compare;
102 typedef _Alloc allocator_type;
106 typedef typename _Alloc::value_type _Alloc_value_type;
107 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
108 __glibcxx_class_requires4(_Compare,
bool, _Key, _Key,
109 _BinaryFunctionConcept)
110 __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept)
116 friend class multimap<_Key, _Tp, _Compare, _Alloc>;
120 value_compare(_Compare __c)
124 bool operator()(
const value_type& __x,
const value_type& __y)
const 131 rebind<value_type>::other _Pair_alloc_type;
133 typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
134 key_compare, _Pair_alloc_type> _Rep_type;
143 typedef typename _Alloc_traits::pointer pointer;
144 typedef typename _Alloc_traits::const_pointer const_pointer;
145 typedef typename _Alloc_traits::reference reference;
146 typedef typename _Alloc_traits::const_reference const_reference;
147 typedef typename _Rep_type::iterator iterator;
148 typedef typename _Rep_type::const_iterator const_iterator;
149 typedef typename _Rep_type::size_type size_type;
150 typedef typename _Rep_type::difference_type difference_type;
161 #if __cplusplus >= 201103L 162 noexcept(is_nothrow_default_constructible<allocator_type>::value)
173 const allocator_type& __a = allocator_type())
174 : _M_t(__comp, _Pair_alloc_type(__a)) { }
186 #if __cplusplus >= 201103L 195 noexcept(is_nothrow_copy_constructible<_Compare>::value)
196 : _M_t(
std::move(__x._M_t)) { }
209 const _Compare& __comp = _Compare(),
210 const allocator_type& __a = allocator_type())
211 : _M_t(__comp, _Pair_alloc_type(__a))
212 { _M_t._M_insert_equal(__l.begin(), __l.end()); }
217 : _M_t(_Compare(), _Pair_alloc_type(__a)) { }
221 : _M_t(__m._M_t, _Pair_alloc_type(__a)) { }
225 noexcept(is_nothrow_copy_constructible<_Compare>::value
226 && _Alloc_traits::_S_always_equal())
227 : _M_t(
std::move(__m._M_t), _Pair_alloc_type(__a)) { }
231 : _M_t(_Compare(), _Pair_alloc_type(__a))
232 { _M_t._M_insert_equal(__l.begin(), __l.end()); }
235 template<
typename _InputIterator>
236 multimap(_InputIterator __first, _InputIterator __last,
237 const allocator_type& __a)
238 : _M_t(_Compare(), _Pair_alloc_type(__a))
239 { _M_t._M_insert_equal(__first, __last); }
251 template<
typename _InputIterator>
252 multimap(_InputIterator __first, _InputIterator __last)
254 { _M_t._M_insert_equal(__first, __last); }
267 template<
typename _InputIterator>
268 multimap(_InputIterator __first, _InputIterator __last,
269 const _Compare& __comp,
270 const allocator_type& __a = allocator_type())
271 : _M_t(__comp, _Pair_alloc_type(__a))
272 { _M_t._M_insert_equal(__first, __last); }
297 #if __cplusplus >= 201103L 316 _M_t._M_assign_equal(__l.begin(), __l.end());
324 {
return allocator_type(_M_t.get_allocator()); }
334 {
return _M_t.begin(); }
343 {
return _M_t.begin(); }
352 {
return _M_t.end(); }
360 end() const _GLIBCXX_NOEXCEPT
361 {
return _M_t.end(); }
370 {
return _M_t.rbegin(); }
377 const_reverse_iterator
379 {
return _M_t.rbegin(); }
388 {
return _M_t.rend(); }
395 const_reverse_iterator
397 {
return _M_t.rend(); }
399 #if __cplusplus >= 201103L 407 {
return _M_t.begin(); }
416 {
return _M_t.end(); }
423 const_reverse_iterator
425 {
return _M_t.rbegin(); }
432 const_reverse_iterator
434 {
return _M_t.rend(); }
441 {
return _M_t.empty(); }
446 {
return _M_t.size(); }
451 {
return _M_t.max_size(); }
454 #if __cplusplus >= 201103L 471 template<
typename... _Args>
474 {
return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); }
498 template<
typename... _Args>
502 return _M_t._M_emplace_hint_equal(__pos,
503 std::forward<_Args>(__args)...);
521 {
return _M_t._M_insert_equal(__x); }
523 #if __cplusplus >= 201103L 524 template<
typename _Pair,
typename =
typename 525 std::enable_if<std::is_constructible<value_type,
526 _Pair&&>::value>::type>
529 {
return _M_t._M_insert_equal(std::forward<_Pair>(__x)); }
553 #if __cplusplus >= 201103L 554 insert(const_iterator __position,
const value_type& __x)
556 insert(iterator __position,
const value_type& __x)
558 {
return _M_t._M_insert_equal_(__position, __x); }
560 #if __cplusplus >= 201103L 561 template<
typename _Pair,
typename =
typename 562 std::enable_if<std::is_constructible<value_type,
563 _Pair&&>::value>::type>
565 insert(const_iterator __position, _Pair&& __x)
566 {
return _M_t._M_insert_equal_(__position,
567 std::forward<_Pair>(__x)); }
579 template<
typename _InputIterator>
581 insert(_InputIterator __first, _InputIterator __last)
582 { _M_t._M_insert_equal(__first, __last); }
584 #if __cplusplus >= 201103L 594 { this->
insert(__l.begin(), __l.end()); }
597 #if __cplusplus >= 201103L 615 {
return _M_t.erase(__position); }
618 _GLIBCXX_ABI_TAG_CXX11
620 erase(iterator __position)
621 {
return _M_t.erase(__position); }
634 erase(iterator __position)
635 { _M_t.erase(__position); }
651 {
return _M_t.erase(__x); }
653 #if __cplusplus >= 201103L 671 erase(const_iterator __first, const_iterator __last)
672 {
return _M_t.erase(__first, __last); }
690 erase(iterator __first, iterator __last)
691 { _M_t.erase(__first, __last); }
707 #if __cplusplus >= 201103L 708 noexcept(_Alloc_traits::_S_nothrow_swap())
710 { _M_t.swap(__x._M_t); }
729 {
return _M_t.key_comp(); }
737 {
return value_compare(_M_t.key_comp()); }
755 {
return _M_t.find(__x); }
757 #if __cplusplus > 201103L 758 template<
typename _Kt>
760 find(
const _Kt& __x) -> decltype(_M_t._M_find_tr(__x))
761 {
return _M_t._M_find_tr(__x); }
778 find(
const key_type& __x)
const 779 {
return _M_t.find(__x); }
781 #if __cplusplus > 201103L 782 template<
typename _Kt>
784 find(
const _Kt& __x)
const -> decltype(_M_t._M_find_tr(__x))
785 {
return _M_t._M_find_tr(__x); }
797 {
return _M_t.count(__x); }
799 #if __cplusplus > 201103L 800 template<
typename _Kt>
802 count(
const _Kt& __x)
const -> decltype(_M_t._M_count_tr(__x))
803 {
return _M_t._M_count_tr(__x); }
821 {
return _M_t.lower_bound(__x); }
823 #if __cplusplus > 201103L 824 template<
typename _Kt>
827 -> decltype(_M_t._M_lower_bound_tr(__x))
828 {
return _M_t._M_lower_bound_tr(__x); }
846 {
return _M_t.lower_bound(__x); }
848 #if __cplusplus > 201103L 849 template<
typename _Kt>
852 -> decltype(_M_t._M_lower_bound_tr(__x))
853 {
return _M_t._M_lower_bound_tr(__x); }
866 {
return _M_t.upper_bound(__x); }
868 #if __cplusplus > 201103L 869 template<
typename _Kt>
872 -> decltype(_M_t._M_upper_bound_tr(__x))
873 {
return _M_t._M_upper_bound_tr(__x); }
886 {
return _M_t.upper_bound(__x); }
888 #if __cplusplus > 201103L 889 template<
typename _Kt>
892 -> decltype(_M_t._M_upper_bound_tr(__x))
893 {
return _M_t._M_upper_bound_tr(__x); }
913 {
return _M_t.equal_range(__x); }
915 #if __cplusplus > 201103L 916 template<
typename _Kt>
919 -> decltype(_M_t._M_equal_range_tr(__x))
920 {
return _M_t._M_equal_range_tr(__x); }
940 {
return _M_t.equal_range(__x); }
942 #if __cplusplus > 201103L 943 template<
typename _Kt>
946 -> decltype(_M_t._M_equal_range_tr(__x))
947 {
return _M_t._M_equal_range_tr(__x); }
951 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
956 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
958 operator<(const multimap<_K1, _T1, _C1, _A1>&,
972 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
976 {
return __x._M_t == __y._M_t; }
989 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
991 operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
993 {
return __x._M_t < __y._M_t; }
996 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1000 {
return !(__x == __y); }
1003 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1007 {
return __y < __x; }
1010 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1012 operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
1014 {
return !(__y < __x); }
1017 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1021 {
return !(__x < __y); }
1024 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1030 _GLIBCXX_END_NAMESPACE_CONTAINER
multimap(initializer_list< value_type > __l, const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())
Builds a multimap from an initializer_list.
reverse_iterator rbegin() noexcept
const_iterator cbegin() const noexcept
auto lower_bound(const _Kt &__x) const -> decltype(_M_t._M_lower_bound_tr(__x))
Finds the beginning of a subsequence matching given key.
key_compare key_comp() const
iterator insert(const_iterator __position, const value_type &__x)
Inserts a std::pair into the multimap.
bool operator>=(const multimap< _Key, _Tp, _Compare, _Alloc > &__x, const multimap< _Key, _Tp, _Compare, _Alloc > &__y)
Based on operator<.
multimap(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a multimap from a range.
const_iterator end() const noexcept
multimap(const multimap &__x)
Multimap copy constructor.
bool empty() const noexcept
multimap(const multimap &__m, const allocator_type &__a)
Allocator-extended copy constructor.
reverse_iterator rend() noexcept
auto upper_bound(const _Kt &__x) -> decltype(_M_t._M_upper_bound_tr(__x))
Finds the end of a subsequence matching given key.
iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a multimap.
The standard allocator, as per [20.4].
size_type erase(const key_type &__x)
Erases elements according to the provided key.
size_type size() const noexcept
auto equal_range(const _Kt &__x) -> decltype(_M_t._M_equal_range_tr(__x))
Finds a subsequence matching given key.
multimap(const allocator_type &__a)
Allocator-extended default constructor.
auto upper_bound(const _Kt &__x) const -> decltype(_M_t._M_upper_bound_tr(__x))
Finds the end of a subsequence matching given key.
void swap(multimap &__x) noexcept(_Alloc_traits::_S_nothrow_swap())
Swaps data with another multimap.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
const_reverse_iterator rbegin() const noexcept
multimap() noexcept(is_nothrow_default_constructible< allocator_type >::value)
Default constructor creates no elements.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
multimap & operator=(initializer_list< value_type > __l)
Multimap list assignment operator.
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
multimap(initializer_list< value_type > __l, const allocator_type &__a)
Allocator-extended initialier-list constructor.
allocator_type get_allocator() const noexcept
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<.
iterator erase(const_iterator __position)
Erases an element from a multimap.
size_type max_size() const noexcept
auto count(const _Kt &__x) const -> decltype(_M_t._M_count_tr(__x))
Finds the number of elements with given key.
A standard container made up of (key,value) pairs, which can be retrieved based on a key...
iterator insert(const value_type &__x)
Inserts a std::pair into the multimap.
One of the comparison functors.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of std::pairs into the multimap.
multimap(multimap &&__x) noexcept(is_nothrow_copy_constructible< _Compare >::value)
Multimap move constructor.
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
bool operator!=(const multimap< _Key, _Tp, _Compare, _Alloc > &__x, const multimap< _Key, _Tp, _Compare, _Alloc > &__y)
Based on operator==.
auto equal_range(const _Kt &__x) const -> decltype(_M_t._M_equal_range_tr(__x))
Finds a subsequence matching given key.
multimap & operator=(const multimap &__x)
Multimap assignment operator.
multimap(_InputIterator __first, _InputIterator __last, const allocator_type &__a)
Allocator-extended range constructor.
const_reverse_iterator crend() const noexcept
iterator emplace(_Args &&...__args)
Build and insert a std::pair into the multimap.
auto lower_bound(const _Kt &__x) -> decltype(_M_t._M_lower_bound_tr(__x))
Finds the beginning of a subsequence matching given key.
void insert(_InputIterator __first, _InputIterator __last)
A template function that attempts to insert a range of elements.
const_reverse_iterator crbegin() const noexcept
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
value_compare value_comp() const
multimap(multimap &&__m, const allocator_type &__a) noexcept(is_nothrow_copy_constructible< _Compare >::value &&_Alloc_traits::_S_always_equal())
Allocator-extended move constructor.
iterator find(const key_type &__x)
Tries to locate an element in a multimap.
Struct holding two objects of arbitrary type.
iterator emplace_hint(const_iterator __pos, _Args &&...__args)
Builds and inserts a std::pair into the multimap.
const_iterator find(const key_type &__x) const
Tries to locate an element in a multimap.
multimap(_InputIterator __first, _InputIterator __last)
Builds a multimap from a range.
const_reverse_iterator rend() const noexcept
const_iterator begin() const noexcept
auto find(const _Kt &__x) -> decltype(_M_t._M_find_tr(__x))
Tries to locate an element in a multimap.
size_type count(const key_type &__x) const
Finds the number of elements with given key.
multimap(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a multimap with no elements.
_T1 first
second_type is the second bound type
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
ISO C++ entities toplevel namespace is std.
Uniform interface to C++98 and C++0x allocators.
const_iterator cend() const noexcept
auto find(const _Kt &__x) const -> decltype(_M_t._M_find_tr(__x))
Tries to locate an element in a multimap.
iterator begin() noexcept
bool operator==(const multimap< _Key, _Tp, _Compare, _Alloc > &__x, const multimap< _Key, _Tp, _Compare, _Alloc > &__y)
Multimap equality comparison.