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
130 typedef typename _Alloc::template rebind<value_type>::other
133 typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
134 key_compare, _Pair_alloc_type> _Rep_type;
141 typedef typename _Pair_alloc_type::pointer pointer;
142 typedef typename _Pair_alloc_type::const_pointer const_pointer;
143 typedef typename _Pair_alloc_type::reference reference;
144 typedef typename _Pair_alloc_type::const_reference const_reference;
145 typedef typename _Rep_type::iterator iterator;
146 typedef typename _Rep_type::const_iterator const_iterator;
147 typedef typename _Rep_type::size_type size_type;
148 typedef typename _Rep_type::difference_type difference_type;
167 const allocator_type& __a = allocator_type())
168 : _M_t(__comp, _Pair_alloc_type(__a)) { }
180 #if __cplusplus >= 201103L
189 noexcept(is_nothrow_copy_constructible<_Compare>::value)
190 : _M_t(
std::
move(__x._M_t)) { }
203 const _Compare& __comp = _Compare(),
204 const allocator_type& __a = allocator_type())
205 : _M_t(__comp, _Pair_alloc_type(__a))
206 { _M_t._M_insert_equal(__l.begin(), __l.end()); }
218 template<
typename _InputIterator>
219 multimap(_InputIterator __first, _InputIterator __last)
221 { _M_t._M_insert_equal(__first, __last); }
234 template<
typename _InputIterator>
235 multimap(_InputIterator __first, _InputIterator __last,
236 const _Compare& __comp,
237 const allocator_type& __a = allocator_type())
238 : _M_t(__comp, _Pair_alloc_type(__a))
239 { _M_t._M_insert_equal(__first, __last); }
264 #if __cplusplus >= 201103L
297 this->
insert(__l.begin(), __l.end());
305 {
return allocator_type(_M_t.get_allocator()); }
315 {
return _M_t.begin(); }
324 {
return _M_t.begin(); }
333 {
return _M_t.end(); }
341 end() const _GLIBCXX_NOEXCEPT
342 {
return _M_t.end(); }
351 {
return _M_t.rbegin(); }
358 const_reverse_iterator
360 {
return _M_t.rbegin(); }
369 {
return _M_t.rend(); }
376 const_reverse_iterator
378 {
return _M_t.rend(); }
380 #if __cplusplus >= 201103L
388 {
return _M_t.begin(); }
397 {
return _M_t.end(); }
404 const_reverse_iterator
406 {
return _M_t.rbegin(); }
413 const_reverse_iterator
415 {
return _M_t.rend(); }
422 {
return _M_t.empty(); }
427 {
return _M_t.size(); }
432 {
return _M_t.max_size(); }
435 #if __cplusplus >= 201103L
452 template<
typename... _Args>
455 {
return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); }
479 template<
typename... _Args>
483 return _M_t._M_emplace_hint_equal(__pos,
484 std::forward<_Args>(__args)...);
502 {
return _M_t._M_insert_equal(__x); }
504 #if __cplusplus >= 201103L
505 template<
typename _Pair,
typename =
typename
506 std::enable_if<std::is_constructible<value_type,
507 _Pair&&>::value>::type>
510 {
return _M_t._M_insert_equal(std::forward<_Pair>(__x)); }
534 #if __cplusplus >= 201103L
535 insert(const_iterator __position,
const value_type& __x)
537 insert(iterator __position,
const value_type& __x)
539 {
return _M_t._M_insert_equal_(__position, __x); }
541 #if __cplusplus >= 201103L
542 template<
typename _Pair,
typename =
typename
543 std::enable_if<std::is_constructible<value_type,
544 _Pair&&>::value>::type>
546 insert(const_iterator __position, _Pair&& __x)
547 {
return _M_t._M_insert_equal_(__position,
548 std::forward<_Pair>(__x)); }
560 template<
typename _InputIterator>
562 insert(_InputIterator __first, _InputIterator __last)
563 { _M_t._M_insert_equal(__first, __last); }
565 #if __cplusplus >= 201103L
575 { this->
insert(__l.begin(), __l.end()); }
578 #if __cplusplus >= 201103L
596 {
return _M_t.erase(__position); }
599 _GLIBCXX_ABI_TAG_CXX11
601 erase(iterator __position)
602 {
return _M_t.erase(__position); }
615 erase(iterator __position)
616 { _M_t.erase(__position); }
632 {
return _M_t.erase(__x); }
634 #if __cplusplus >= 201103L
652 erase(const_iterator __first, const_iterator __last)
653 {
return _M_t.erase(__first, __last); }
671 erase(iterator __first, iterator __last)
672 { _M_t.erase(__first, __last); }
688 { _M_t.swap(__x._M_t); }
707 {
return _M_t.key_comp(); }
715 {
return value_compare(_M_t.key_comp()); }
731 {
return _M_t.find(__x); }
745 find(
const key_type& __x)
const
746 {
return _M_t.find(__x); }
755 {
return _M_t.count(__x); }
770 {
return _M_t.lower_bound(__x); }
785 {
return _M_t.lower_bound(__x); }
795 {
return _M_t.upper_bound(__x); }
805 {
return _M_t.upper_bound(__x); }
822 {
return _M_t.equal_range(__x); }
839 {
return _M_t.equal_range(__x); }
841 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
846 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
848 operator<(const multimap<_K1, _T1, _C1, _A1>&,
862 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
866 {
return __x._M_t == __y._M_t; }
879 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
881 operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
883 {
return __x._M_t < __y._M_t; }
886 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
890 {
return !(__x == __y); }
893 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
897 {
return __y < __x; }
900 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
902 operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
904 {
return !(__y < __x); }
907 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
911 {
return !(__x < __y); }
914 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
920 _GLIBCXX_END_NAMESPACE_CONTAINER
const_reverse_iterator rend() const noexcept
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.
reverse_iterator rend() noexcept
bool operator!=(const multimap< _Key, _Tp, _Compare, _Alloc > &__x, const multimap< _Key, _Tp, _Compare, _Alloc > &__y)
Based on operator==.
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
multimap()
Default constructor creates no elements.
iterator emplace_hint(const_iterator __pos, _Args &&...__args)
Builds and inserts a std::pair into the multimap.
const_reverse_iterator crbegin() const noexcept
const_reverse_iterator rbegin() const noexcept
iterator insert(const_iterator __position, const value_type &__x)
Inserts a std::pair into the multimap.
value_compare value_comp() const
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
const_iterator begin() const noexcept
One of the comparison functors.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of std::pairs into the multimap.
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.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
const_reverse_iterator crend() const noexcept
const_iterator find(const key_type &__x) const
Tries to locate an element in a multimap.
iterator erase(const_iterator __position)
Erases an element from a multimap.
bool operator>=(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string doesn't precede string.
multimap(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a multimap from a range.
ISO C++ entities toplevel namespace is std.
bool empty() const noexcept
_T1 first
second_type is the second bound type
iterator find(const key_type &__x)
Tries to locate an element in a multimap.
const_iterator cbegin() const noexcept
multimap(_InputIterator __first, _InputIterator __last)
Builds a multimap from a range.
multimap(initializer_list< value_type > __l, const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())
Builds a multimap from an initializer_list.
size_type size() const noexcept
void swap(multimap &__x)
Swaps data with another multimap.
multimap & operator=(multimap &&__x)
Multimap move assignment operator.
A standard container made up of (key,value) pairs, which can be retrieved based on a key...
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.
size_type max_size() const noexcept
void swap(_Tp &, _Tp &) noexcept(__and_< is_nothrow_move_constructible< _Tp >, is_nothrow_move_assignable< _Tp >>::value)
Swaps two values.
bool operator==(const multimap< _Key, _Tp, _Compare, _Alloc > &__x, const multimap< _Key, _Tp, _Compare, _Alloc > &__y)
Multimap equality comparison.
multimap & operator=(initializer_list< value_type > __l)
Multimap list assignment operator.
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
Struct holding two objects of arbitrary type.
multimap & operator=(const multimap &__x)
Multimap assignment operator.
The standard allocator, as per [20.4].
key_compare key_comp() const
multimap(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a multimap with no elements.
reverse_iterator rbegin() noexcept
iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a multimap.
iterator insert(const value_type &__x)
Inserts a std::pair into the multimap.
bool operator>(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string follows string.