56 #ifndef _STL_MULTIMAP_H
57 #define _STL_MULTIMAP_H 1
60 #if __cplusplus >= 201103L
61 #include <initializer_list>
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;
170 const allocator_type& __a = allocator_type())
171 : _M_t(__comp, _Pair_alloc_type(__a)) { }
183 #if __cplusplus >= 201103L
192 noexcept(is_nothrow_copy_constructible<_Compare>::value)
193 : _M_t(
std::
move(__x._M_t)) { }
206 const _Compare& __comp = _Compare(),
207 const allocator_type& __a = allocator_type())
208 : _M_t(__comp, _Pair_alloc_type(__a))
209 { _M_t._M_insert_equal(__l.begin(), __l.end()); }
214 : _M_t(_Compare(), _Pair_alloc_type(__a)) { }
218 : _M_t(__m._M_t, _Pair_alloc_type(__a)) { }
222 noexcept(is_nothrow_copy_constructible<_Compare>::value
223 && _Alloc_traits::_S_always_equal())
224 : _M_t(
std::
move(__m._M_t), _Pair_alloc_type(__a)) { }
227 multimap(initializer_list<value_type> __l,
const allocator_type& __a)
228 : _M_t(_Compare(), _Pair_alloc_type(__a))
229 { _M_t._M_insert_equal(__l.begin(), __l.end()); }
232 template<
typename _InputIterator>
233 multimap(_InputIterator __first, _InputIterator __last,
234 const allocator_type& __a)
235 : _M_t(_Compare(), _Pair_alloc_type(__a))
236 { _M_t._M_insert_equal(__first, __last); }
248 template<
typename _InputIterator>
249 multimap(_InputIterator __first, _InputIterator __last)
251 { _M_t._M_insert_equal(__first, __last); }
264 template<
typename _InputIterator>
265 multimap(_InputIterator __first, _InputIterator __last,
266 const _Compare& __comp,
267 const allocator_type& __a = allocator_type())
268 : _M_t(__comp, _Pair_alloc_type(__a))
269 { _M_t._M_insert_equal(__first, __last); }
294 #if __cplusplus >= 201103L
313 _M_t._M_assign_equal(__l.begin(), __l.end());
321 {
return allocator_type(_M_t.get_allocator()); }
331 {
return _M_t.begin(); }
340 {
return _M_t.begin(); }
349 {
return _M_t.end(); }
357 end() const _GLIBCXX_NOEXCEPT
358 {
return _M_t.end(); }
367 {
return _M_t.rbegin(); }
374 const_reverse_iterator
376 {
return _M_t.rbegin(); }
385 {
return _M_t.rend(); }
392 const_reverse_iterator
394 {
return _M_t.rend(); }
396 #if __cplusplus >= 201103L
404 {
return _M_t.begin(); }
413 {
return _M_t.end(); }
420 const_reverse_iterator
422 {
return _M_t.rbegin(); }
429 const_reverse_iterator
431 {
return _M_t.rend(); }
438 {
return _M_t.empty(); }
443 {
return _M_t.size(); }
448 {
return _M_t.max_size(); }
451 #if __cplusplus >= 201103L
468 template<
typename... _Args>
471 {
return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); }
495 template<
typename... _Args>
499 return _M_t._M_emplace_hint_equal(__pos,
500 std::forward<_Args>(__args)...);
518 {
return _M_t._M_insert_equal(__x); }
520 #if __cplusplus >= 201103L
521 template<
typename _Pair,
typename =
typename
522 std::enable_if<std::is_constructible<value_type,
523 _Pair&&>::value>::type>
526 {
return _M_t._M_insert_equal(std::forward<_Pair>(__x)); }
550 #if __cplusplus >= 201103L
551 insert(const_iterator __position,
const value_type& __x)
553 insert(iterator __position,
const value_type& __x)
555 {
return _M_t._M_insert_equal_(__position, __x); }
557 #if __cplusplus >= 201103L
558 template<
typename _Pair,
typename =
typename
559 std::enable_if<std::is_constructible<value_type,
560 _Pair&&>::value>::type>
562 insert(const_iterator __position, _Pair&& __x)
563 {
return _M_t._M_insert_equal_(__position,
564 std::forward<_Pair>(__x)); }
576 template<
typename _InputIterator>
578 insert(_InputIterator __first, _InputIterator __last)
579 { _M_t._M_insert_equal(__first, __last); }
581 #if __cplusplus >= 201103L
591 { this->
insert(__l.begin(), __l.end()); }
594 #if __cplusplus >= 201103L
612 {
return _M_t.erase(__position); }
615 _GLIBCXX_ABI_TAG_CXX11
617 erase(iterator __position)
618 {
return _M_t.erase(__position); }
631 erase(iterator __position)
632 { _M_t.erase(__position); }
648 {
return _M_t.erase(__x); }
650 #if __cplusplus >= 201103L
668 erase(const_iterator __first, const_iterator __last)
669 {
return _M_t.erase(__first, __last); }
687 erase(iterator __first, iterator __last)
688 { _M_t.erase(__first, __last); }
704 #if __cplusplus >= 201103L
705 noexcept(_Alloc_traits::_S_nothrow_swap())
707 { _M_t.swap(__x._M_t); }
726 {
return _M_t.key_comp(); }
734 {
return value_compare(_M_t.key_comp()); }
752 {
return _M_t.find(__x); }
754 #if __cplusplus > 201103L
755 template<
typename _Kt>
757 find(
const _Kt& __x) -> decltype(_M_t._M_find_tr(__x))
758 {
return _M_t._M_find_tr(__x); }
775 find(
const key_type& __x)
const
776 {
return _M_t.find(__x); }
778 #if __cplusplus > 201103L
779 template<
typename _Kt>
781 find(
const _Kt& __x)
const -> decltype(_M_t._M_find_tr(__x))
782 {
return _M_t._M_find_tr(__x); }
794 {
return _M_t.count(__x); }
796 #if __cplusplus > 201103L
797 template<
typename _Kt>
799 count(
const _Kt& __x)
const -> decltype(_M_t._M_count_tr(__x))
800 {
return _M_t._M_count_tr(__x); }
818 {
return _M_t.lower_bound(__x); }
820 #if __cplusplus > 201103L
821 template<
typename _Kt>
824 -> decltype(_M_t._M_lower_bound_tr(__x))
825 {
return _M_t._M_lower_bound_tr(__x); }
843 {
return _M_t.lower_bound(__x); }
845 #if __cplusplus > 201103L
846 template<
typename _Kt>
849 -> decltype(_M_t._M_lower_bound_tr(__x))
850 {
return _M_t._M_lower_bound_tr(__x); }
863 {
return _M_t.upper_bound(__x); }
865 #if __cplusplus > 201103L
866 template<
typename _Kt>
869 -> decltype(_M_t._M_upper_bound_tr(__x))
870 {
return _M_t._M_upper_bound_tr(__x); }
883 {
return _M_t.upper_bound(__x); }
885 #if __cplusplus > 201103L
886 template<
typename _Kt>
889 -> decltype(_M_t._M_upper_bound_tr(__x))
890 {
return _M_t._M_upper_bound_tr(__x); }
910 {
return _M_t.equal_range(__x); }
912 #if __cplusplus > 201103L
913 template<
typename _Kt>
916 -> decltype(_M_t._M_equal_range_tr(__x))
917 {
return _M_t._M_equal_range_tr(__x); }
937 {
return _M_t.equal_range(__x); }
939 #if __cplusplus > 201103L
940 template<
typename _Kt>
943 -> decltype(_M_t._M_equal_range_tr(__x))
944 {
return _M_t._M_equal_range_tr(__x); }
948 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
950 operator==(
const multimap<_K1, _T1, _C1, _A1>&,
951 const multimap<_K1, _T1, _C1, _A1>&);
953 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
955 operator<(const multimap<_K1, _T1, _C1, _A1>&,
956 const multimap<_K1, _T1, _C1, _A1>&);
969 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
973 {
return __x._M_t == __y._M_t; }
986 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
988 operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
990 {
return __x._M_t < __y._M_t; }
993 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
997 {
return !(__x == __y); }
1000 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1004 {
return __y < __x; }
1007 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1009 operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
1011 {
return !(__y < __x); }
1014 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1018 {
return !(__x < __y); }
1021 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1027 _GLIBCXX_END_NAMESPACE_CONTAINER
void swap(_Tp &, _Tp &) noexcept(__and_< is_nothrow_move_constructible< _Tp >, is_nothrow_move_assignable< _Tp >>::value)
Swaps two values.
multimap(multimap &&__m, const allocator_type &__a) noexcept(is_nothrow_copy_constructible< _Compare >::value &&_Alloc_traits::_S_always_equal())
Allocator-extended move constructor.
const_reverse_iterator crbegin() const noexcept
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
multimap & operator=(const multimap &__x)
Multimap assignment operator.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
const_iterator begin() const noexcept
multimap(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a multimap with no elements.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
const_iterator cend() const noexcept
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
Uniform interface to C++98 and C++0x allocators.
const_reverse_iterator crend() const noexcept
iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a multimap.
iterator erase(const_iterator __position)
Erases an element from a multimap.
bool operator!=(const multimap< _Key, _Tp, _Compare, _Alloc > &__x, const multimap< _Key, _Tp, _Compare, _Alloc > &__y)
Based on operator==.
bool operator>=(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string doesn't precede string.
A standard container made up of (key,value) pairs, which can be retrieved based on a key...
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
multimap(multimap &&__x) noexcept(is_nothrow_copy_constructible< _Compare >::value)
Multimap move constructor.
multimap(const multimap &__m, const allocator_type &__a)
Allocator-extended copy constructor.
bool empty() const noexcept
_T1 first
second_type is the second bound type
multimap(_InputIterator __first, _InputIterator __last)
Builds a multimap from a range.
multimap()
Default constructor creates no elements.
multimap(initializer_list< value_type > __l, const allocator_type &__a)
Allocator-extended initialier-list constructor.
iterator emplace_hint(const_iterator __pos, _Args &&...__args)
Builds and inserts a std::pair into the multimap.
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
size_type size() const noexcept
iterator insert(const_iterator __position, const value_type &__x)
Inserts a std::pair into the multimap.
value_compare value_comp() const
bool operator>(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string follows string.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of std::pairs into the multimap.
iterator begin() noexcept
size_type count(const key_type &__x) const
Finds the number of elements with given key.
iterator emplace(_Args &&...__args)
Build and insert a std::pair into the multimap.
const_iterator find(const key_type &__x) const
Tries to locate an element in a multimap.
size_type max_size() const noexcept
bool operator==(const multimap< _Key, _Tp, _Compare, _Alloc > &__x, const multimap< _Key, _Tp, _Compare, _Alloc > &__y)
Multimap equality comparison.
multimap(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a multimap from a range.
multimap(_InputIterator __first, _InputIterator __last, const allocator_type &__a)
Allocator-extended range constructor.
The standard allocator, as per [20.4].
multimap(const multimap &__x)
Multimap copy constructor.
void insert(_InputIterator __first, _InputIterator __last)
A template function that attempts to insert a range of elements.
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
const_iterator end() const noexcept
iterator find(const key_type &__x)
Tries to locate an element in a multimap.
const_iterator cbegin() const noexcept
key_compare key_comp() const
Struct holding two objects of arbitrary type.
reverse_iterator rbegin() noexcept
iterator insert(const value_type &__x)
Inserts a std::pair into the multimap.
void swap(multimap &__x) noexcept(_Alloc_traits::_S_nothrow_swap())
Swaps data with another multimap.
const_reverse_iterator rend() const noexcept
reverse_iterator rend() noexcept
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
ISO C++ entities toplevel namespace is std.
multimap & operator=(initializer_list< value_type > __l)
Multimap list assignment operator.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
multimap(const allocator_type &__a)
Allocator-extended default constructor.
One of the comparison functors.