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
163 && is_nothrow_default_constructible<key_compare>::value)
174 const allocator_type& __a = allocator_type())
175 : _M_t(__comp, _Pair_alloc_type(__a)) { }
187 #if __cplusplus >= 201103L 196 noexcept(is_nothrow_copy_constructible<_Compare>::value)
197 : _M_t(
std::move(__x._M_t)) { }
210 const _Compare& __comp = _Compare(),
211 const allocator_type& __a = allocator_type())
212 : _M_t(__comp, _Pair_alloc_type(__a))
213 { _M_t._M_insert_equal(__l.begin(), __l.end()); }
218 : _M_t(_Compare(), _Pair_alloc_type(__a)) { }
222 : _M_t(__m._M_t, _Pair_alloc_type(__a)) { }
226 noexcept(is_nothrow_copy_constructible<_Compare>::value
227 && _Alloc_traits::_S_always_equal())
228 : _M_t(
std::move(__m._M_t), _Pair_alloc_type(__a)) { }
232 : _M_t(_Compare(), _Pair_alloc_type(__a))
233 { _M_t._M_insert_equal(__l.begin(), __l.end()); }
236 template<
typename _InputIterator>
237 multimap(_InputIterator __first, _InputIterator __last,
238 const allocator_type& __a)
239 : _M_t(_Compare(), _Pair_alloc_type(__a))
240 { _M_t._M_insert_equal(__first, __last); }
252 template<
typename _InputIterator>
253 multimap(_InputIterator __first, _InputIterator __last)
255 { _M_t._M_insert_equal(__first, __last); }
268 template<
typename _InputIterator>
269 multimap(_InputIterator __first, _InputIterator __last,
270 const _Compare& __comp,
271 const allocator_type& __a = allocator_type())
272 : _M_t(__comp, _Pair_alloc_type(__a))
273 { _M_t._M_insert_equal(__first, __last); }
298 #if __cplusplus >= 201103L 317 _M_t._M_assign_equal(__l.begin(), __l.end());
325 {
return allocator_type(_M_t.get_allocator()); }
335 {
return _M_t.begin(); }
344 {
return _M_t.begin(); }
353 {
return _M_t.end(); }
361 end() const _GLIBCXX_NOEXCEPT
362 {
return _M_t.end(); }
371 {
return _M_t.rbegin(); }
378 const_reverse_iterator
380 {
return _M_t.rbegin(); }
389 {
return _M_t.rend(); }
396 const_reverse_iterator
398 {
return _M_t.rend(); }
400 #if __cplusplus >= 201103L 408 {
return _M_t.begin(); }
417 {
return _M_t.end(); }
424 const_reverse_iterator
426 {
return _M_t.rbegin(); }
433 const_reverse_iterator
435 {
return _M_t.rend(); }
442 {
return _M_t.empty(); }
447 {
return _M_t.size(); }
452 {
return _M_t.max_size(); }
455 #if __cplusplus >= 201103L 472 template<
typename... _Args>
475 {
return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); }
499 template<
typename... _Args>
503 return _M_t._M_emplace_hint_equal(__pos,
504 std::forward<_Args>(__args)...);
522 {
return _M_t._M_insert_equal(__x); }
524 #if __cplusplus >= 201103L 525 template<
typename _Pair,
typename =
typename 526 std::enable_if<std::is_constructible<value_type,
527 _Pair&&>::value>::type>
530 {
return _M_t._M_insert_equal(std::forward<_Pair>(__x)); }
554 #if __cplusplus >= 201103L 555 insert(const_iterator __position,
const value_type& __x)
557 insert(iterator __position,
const value_type& __x)
559 {
return _M_t._M_insert_equal_(__position, __x); }
561 #if __cplusplus >= 201103L 562 template<
typename _Pair,
typename =
typename 563 std::enable_if<std::is_constructible<value_type,
564 _Pair&&>::value>::type>
566 insert(const_iterator __position, _Pair&& __x)
567 {
return _M_t._M_insert_equal_(__position,
568 std::forward<_Pair>(__x)); }
580 template<
typename _InputIterator>
582 insert(_InputIterator __first, _InputIterator __last)
583 { _M_t._M_insert_equal(__first, __last); }
585 #if __cplusplus >= 201103L 595 { this->
insert(__l.begin(), __l.end()); }
598 #if __cplusplus >= 201103L 616 {
return _M_t.erase(__position); }
619 _GLIBCXX_ABI_TAG_CXX11
621 erase(iterator __position)
622 {
return _M_t.erase(__position); }
635 erase(iterator __position)
636 { _M_t.erase(__position); }
652 {
return _M_t.erase(__x); }
654 #if __cplusplus >= 201103L 672 erase(const_iterator __first, const_iterator __last)
673 {
return _M_t.erase(__first, __last); }
691 erase(iterator __first, iterator __last)
692 { _M_t.erase(__first, __last); }
708 #if __cplusplus >= 201103L 709 noexcept(_Alloc_traits::_S_nothrow_swap())
711 { _M_t.swap(__x._M_t); }
730 {
return _M_t.key_comp(); }
738 {
return value_compare(_M_t.key_comp()); }
756 {
return _M_t.find(__x); }
758 #if __cplusplus > 201103L 759 template<
typename _Kt>
761 find(
const _Kt& __x) -> decltype(_M_t._M_find_tr(__x))
762 {
return _M_t._M_find_tr(__x); }
779 find(
const key_type& __x)
const 780 {
return _M_t.find(__x); }
782 #if __cplusplus > 201103L 783 template<
typename _Kt>
785 find(
const _Kt& __x)
const -> decltype(_M_t._M_find_tr(__x))
786 {
return _M_t._M_find_tr(__x); }
798 {
return _M_t.count(__x); }
800 #if __cplusplus > 201103L 801 template<
typename _Kt>
803 count(
const _Kt& __x)
const -> decltype(_M_t._M_count_tr(__x))
804 {
return _M_t._M_count_tr(__x); }
822 {
return _M_t.lower_bound(__x); }
824 #if __cplusplus > 201103L 825 template<
typename _Kt>
828 -> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
829 {
return iterator(_M_t._M_lower_bound_tr(__x)); }
847 {
return _M_t.lower_bound(__x); }
849 #if __cplusplus > 201103L 850 template<
typename _Kt>
853 -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x)))
854 {
return const_iterator(_M_t._M_lower_bound_tr(__x)); }
867 {
return _M_t.upper_bound(__x); }
869 #if __cplusplus > 201103L 870 template<
typename _Kt>
873 -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
874 {
return iterator(_M_t._M_upper_bound_tr(__x)); }
887 {
return _M_t.upper_bound(__x); }
889 #if __cplusplus > 201103L 890 template<
typename _Kt>
893 -> decltype(const_iterator(_M_t._M_upper_bound_tr(__x)))
894 {
return const_iterator(_M_t._M_upper_bound_tr(__x)); }
914 {
return _M_t.equal_range(__x); }
916 #if __cplusplus > 201103L 917 template<
typename _Kt>
941 {
return _M_t.equal_range(__x); }
943 #if __cplusplus > 201103L 944 template<
typename _Kt>
948 _M_t._M_equal_range_tr(__x)))
951 _M_t._M_equal_range_tr(__x));
956 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
961 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
963 operator<(const multimap<_K1, _T1, _C1, _A1>&,
977 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
981 {
return __x._M_t == __y._M_t; }
994 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
996 operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
998 {
return __x._M_t < __y._M_t; }
1001 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1005 {
return !(__x == __y); }
1008 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1012 {
return __y < __x; }
1015 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1017 operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
1019 {
return !(__y < __x); }
1022 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1026 {
return !(__x < __y); }
1029 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1035 _GLIBCXX_END_NAMESPACE_CONTAINER
auto lower_bound(const _Kt &__x) -> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
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)
Multimap equality comparison.
auto count(const _Kt &__x) const -> decltype(_M_t._M_count_tr(__x))
Finds the number of elements with given key.
const_reverse_iterator crbegin() const noexcept
const_iterator begin() const noexcept
key_compare key_comp() const
reverse_iterator rbegin() noexcept
size_type count(const key_type &__x) const
Finds the number of elements with given key.
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
multimap(const multimap &__m, const allocator_type &__a)
Allocator-extended copy constructor.
iterator insert(const value_type &__x)
Inserts a std::pair into the multimap.
void insert(_InputIterator __first, _InputIterator __last)
A template function that attempts to insert a range of elements.
auto lower_bound(const _Kt &__x) const -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x)))
Finds the beginning of a subsequence matching given key.
iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a multimap.
multimap(const allocator_type &__a)
Allocator-extended default constructor.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
multimap & operator=(initializer_list< value_type > __l)
Multimap list assignment operator.
reverse_iterator rend() noexcept
multimap(_InputIterator __first, _InputIterator __last, const allocator_type &__a)
Allocator-extended range constructor.
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.
One of the comparison functors.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
iterator emplace(_Args &&... __args)
Build and insert a std::pair into the multimap.
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of std::pairs into the multimap.
multimap(_InputIterator __first, _InputIterator __last)
Builds a multimap from a range.
value_compare value_comp() const
const_iterator find(const key_type &__x) const
Tries to locate an element in a multimap.
Uniform interface to C++98 and C++0x allocators.
ISO C++ entities toplevel namespace is std.
const_iterator cbegin() const noexcept
iterator emplace_hint(const_iterator __pos, _Args &&... __args)
Builds and inserts a std::pair into the multimap.
iterator insert(const_iterator __position, const value_type &__x)
Inserts a std::pair into the multimap.
size_type max_size() const noexcept
bool operator!=(const multimap< _Key, _Tp, _Compare, _Alloc > &__x, const multimap< _Key, _Tp, _Compare, _Alloc > &__y)
Based on operator==.
multimap & operator=(const multimap &__x)
Multimap assignment operator.
auto upper_bound(const _Kt &__x) -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
Finds the end of a subsequence matching given key.
multimap(multimap &&__x) noexcept(is_nothrow_copy_constructible< _Compare >::value)
Multimap move constructor.
Struct holding two objects of arbitrary type.
auto upper_bound(const _Kt &__x) const -> decltype(const_iterator(_M_t._M_upper_bound_tr(__x)))
Finds the end 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) -> decltype(pair< iterator, iterator >(_M_t._M_equal_range_tr(__x)))
Finds a subsequence matching given key.
The standard allocator, as per [20.4].
bool empty() const noexcept
auto find(const _Kt &__x) -> decltype(_M_t._M_find_tr(__x))
Tries to locate an element in a multimap.
multimap(multimap &&__m, const allocator_type &__a) noexcept(is_nothrow_copy_constructible< _Compare >::value &&_Alloc_traits::_S_always_equal())
Allocator-extended move constructor.
multimap(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a multimap from a range.
A standard container made up of (key,value) pairs, which can be retrieved based on a 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(pair< const_iterator, const_iterator >(_M_t._M_equal_range_tr(__x)))
Finds a subsequence matching given key.
const_iterator cend() const noexcept
const_reverse_iterator crend() const noexcept
void swap(multimap &__x) noexcept(_Alloc_traits::_S_nothrow_swap())
Swaps data with another multimap.
iterator find(const key_type &__x)
Tries to locate an element in a multimap.
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
iterator erase(const_iterator __position)
Erases an element from a multimap.
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
multimap() noexcept(is_nothrow_default_constructible< allocator_type >::value &&is_nothrow_default_constructible< key_compare >::value)
Default constructor creates no elements.
multimap(const multimap &__x)
Multimap copy constructor.
_T1 first
second_type is the second bound type
multimap(initializer_list< value_type > __l, const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())
Builds a multimap from an initializer_list.
const_reverse_iterator rbegin() const noexcept
const_iterator end() const noexcept
iterator begin() noexcept
const_reverse_iterator rend() const noexcept
auto find(const _Kt &__x) const -> decltype(_M_t._M_find_tr(__x))
Tries to locate an element in a multimap.
multimap(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a multimap with no elements.
size_type size() const noexcept