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
306 if (!_M_t._M_move_assign(__x._M_t))
311 insert(std::__make_move_if_noexcept_iterator(__x.begin()),
312 std::__make_move_if_noexcept_iterator(__x.end()));
333 this->
insert(__l.begin(), __l.end());
341 {
return allocator_type(_M_t.get_allocator()); }
351 {
return _M_t.begin(); }
360 {
return _M_t.begin(); }
369 {
return _M_t.end(); }
377 end() const _GLIBCXX_NOEXCEPT
378 {
return _M_t.end(); }
387 {
return _M_t.rbegin(); }
394 const_reverse_iterator
396 {
return _M_t.rbegin(); }
405 {
return _M_t.rend(); }
412 const_reverse_iterator
414 {
return _M_t.rend(); }
416 #if __cplusplus >= 201103L
424 {
return _M_t.begin(); }
433 {
return _M_t.end(); }
440 const_reverse_iterator
442 {
return _M_t.rbegin(); }
449 const_reverse_iterator
451 {
return _M_t.rend(); }
458 {
return _M_t.empty(); }
463 {
return _M_t.size(); }
468 {
return _M_t.max_size(); }
471 #if __cplusplus >= 201103L
488 template<
typename... _Args>
491 {
return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); }
515 template<
typename... _Args>
519 return _M_t._M_emplace_hint_equal(__pos,
520 std::forward<_Args>(__args)...);
538 {
return _M_t._M_insert_equal(__x); }
540 #if __cplusplus >= 201103L
541 template<
typename _Pair,
typename =
typename
542 std::enable_if<std::is_constructible<value_type,
543 _Pair&&>::value>::type>
546 {
return _M_t._M_insert_equal(std::forward<_Pair>(__x)); }
570 #if __cplusplus >= 201103L
571 insert(const_iterator __position,
const value_type& __x)
573 insert(iterator __position,
const value_type& __x)
575 {
return _M_t._M_insert_equal_(__position, __x); }
577 #if __cplusplus >= 201103L
578 template<
typename _Pair,
typename =
typename
579 std::enable_if<std::is_constructible<value_type,
580 _Pair&&>::value>::type>
582 insert(const_iterator __position, _Pair&& __x)
583 {
return _M_t._M_insert_equal_(__position,
584 std::forward<_Pair>(__x)); }
596 template<
typename _InputIterator>
598 insert(_InputIterator __first, _InputIterator __last)
599 { _M_t._M_insert_equal(__first, __last); }
601 #if __cplusplus >= 201103L
611 { this->
insert(__l.begin(), __l.end()); }
614 #if __cplusplus >= 201103L
632 {
return _M_t.erase(__position); }
635 _GLIBCXX_ABI_TAG_CXX11
637 erase(iterator __position)
638 {
return _M_t.erase(__position); }
651 erase(iterator __position)
652 { _M_t.erase(__position); }
668 {
return _M_t.erase(__x); }
670 #if __cplusplus >= 201103L
688 erase(const_iterator __first, const_iterator __last)
689 {
return _M_t.erase(__first, __last); }
707 erase(iterator __first, iterator __last)
708 { _M_t.erase(__first, __last); }
724 #if __cplusplus >= 201103L
725 noexcept(_Alloc_traits::_S_nothrow_swap())
727 { _M_t.swap(__x._M_t); }
746 {
return _M_t.key_comp(); }
754 {
return value_compare(_M_t.key_comp()); }
770 {
return _M_t.find(__x); }
784 find(
const key_type& __x)
const
785 {
return _M_t.find(__x); }
794 {
return _M_t.count(__x); }
809 {
return _M_t.lower_bound(__x); }
824 {
return _M_t.lower_bound(__x); }
834 {
return _M_t.upper_bound(__x); }
844 {
return _M_t.upper_bound(__x); }
861 {
return _M_t.equal_range(__x); }
878 {
return _M_t.equal_range(__x); }
880 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
885 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
887 operator<(const multimap<_K1, _T1, _C1, _A1>&,
901 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
905 {
return __x._M_t == __y._M_t; }
918 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
920 operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
922 {
return __x._M_t < __y._M_t; }
925 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
929 {
return !(__x == __y); }
932 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
936 {
return __y < __x; }
939 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
941 operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
943 {
return !(__y < __x); }
946 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
950 {
return !(__x < __y); }
953 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
959 _GLIBCXX_END_NAMESPACE_CONTAINER
multimap(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a multimap from a range.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
size_type size() const noexcept
multimap()
Default constructor creates no elements.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
value_compare value_comp() const
multimap(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a multimap with no elements.
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
Uniform interface to C++98 and C++0x allocators.
bool operator!=(const multimap< _Key, _Tp, _Compare, _Alloc > &__x, const multimap< _Key, _Tp, _Compare, _Alloc > &__y)
Based on operator==.
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
multimap(multimap &&__m, const allocator_type &__a) noexcept(is_nothrow_copy_constructible< _Compare >::value &&_Alloc_traits::_S_always_equal())
Allocator-extended move constructor.
iterator emplace(_Args &&...__args)
Build and insert a std::pair into the multimap.
multimap(_InputIterator __first, _InputIterator __last, const allocator_type &__a)
Allocator-extended range constructor.
multimap & operator=(multimap &&__x) noexcept(_Alloc_traits::_S_nothrow_move())
Multimap move assignment operator.
iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a multimap.
const_reverse_iterator crbegin() const noexcept
bool operator==(const multimap< _Key, _Tp, _Compare, _Alloc > &__x, const multimap< _Key, _Tp, _Compare, _Alloc > &__y)
Multimap equality comparison.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of std::pairs into the multimap.
const_reverse_iterator crend() const noexcept
iterator emplace_hint(const_iterator __pos, _Args &&...__args)
Builds and inserts a std::pair into the multimap.
const_iterator end() const noexcept
bool empty() const noexcept
key_compare key_comp() const
iterator begin() noexcept
reverse_iterator rbegin() noexcept
_T1 first
second_type is the second bound type
ISO C++ entities toplevel namespace is std.
multimap(_InputIterator __first, _InputIterator __last)
Builds a multimap from a range.
iterator erase(const_iterator __position)
Erases an element from a multimap.
multimap(initializer_list< value_type > __l, const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())
Builds a multimap from an initializer_list.
multimap(const multimap &__x)
Multimap copy constructor.
void swap(multimap &__x) noexcept(_Alloc_traits::_S_nothrow_swap())
Swaps data with another multimap.
The standard allocator, as per [20.4].
multimap(multimap &&__x) noexcept(is_nothrow_copy_constructible< _Compare >::value)
Multimap move constructor.
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
multimap(initializer_list< value_type > __l, const allocator_type &__a)
Allocator-extended initialier-list constructor.
const_reverse_iterator rbegin() const noexcept
size_type count(const key_type &__x) const
Finds the number of elements with given key.
const_iterator begin() const noexcept
multimap & operator=(initializer_list< value_type > __l)
Multimap list assignment operator.
multimap & operator=(const multimap &__x)
Multimap assignment operator.
size_type max_size() const noexcept
bool operator>=(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string doesn't precede string.
iterator insert(const value_type &__x)
Inserts a std::pair into the multimap.
multimap(const multimap &__m, const allocator_type &__a)
Allocator-extended copy constructor.
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
const_iterator cbegin() const noexcept
const_iterator cend() const noexcept
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 (key,value) pairs, which can be retrieved based on a key...
bool operator>(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string follows string.
const_iterator find(const key_type &__x) const
Tries to locate an element in a multimap.
reverse_iterator rend() noexcept
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
Struct holding two objects of arbitrary type.
void swap(_Tp &, _Tp &) noexcept(__and_< is_nothrow_move_constructible< _Tp >, is_nothrow_move_assignable< _Tp >>::value)
Swaps two values.
One of the comparison functors.
void insert(_InputIterator __first, _InputIterator __last)
A template function that attempts to insert a range of elements.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
iterator insert(const_iterator __position, const value_type &__x)
Inserts a std::pair into the multimap.
const_reverse_iterator rend() const noexcept
multimap(const allocator_type &__a)
Allocator-extended default constructor.
iterator find(const key_type &__x)
Tries to locate an element in a multimap.