61 #if __cplusplus >= 201103L
62 #include <initializer_list>
66 namespace std _GLIBCXX_VISIBILITY(default)
68 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
94 template <
typename _Key,
typename _Tp,
typename _Compare = std::less<_Key>,
95 typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
99 typedef _Key key_type;
100 typedef _Tp mapped_type;
102 typedef _Compare key_compare;
103 typedef _Alloc allocator_type;
107 typedef typename _Alloc::value_type _Alloc_value_type;
108 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
109 __glibcxx_class_requires4(_Compare,
bool, _Key, _Key,
110 _BinaryFunctionConcept)
111 __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept)
117 friend class map<_Key, _Tp, _Compare, _Alloc>;
121 value_compare(_Compare __c)
125 bool operator()(
const value_type& __x,
const value_type& __y)
const
132 rebind<value_type>::other _Pair_alloc_type;
134 typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
135 key_compare, _Pair_alloc_type> _Rep_type;
145 typedef typename _Alloc_traits::pointer pointer;
146 typedef typename _Alloc_traits::const_pointer const_pointer;
147 typedef typename _Alloc_traits::reference reference;
148 typedef typename _Alloc_traits::const_reference const_reference;
149 typedef typename _Rep_type::iterator iterator;
150 typedef typename _Rep_type::const_iterator const_iterator;
151 typedef typename _Rep_type::size_type size_type;
152 typedef typename _Rep_type::difference_type difference_type;
171 map(
const _Compare& __comp,
172 const allocator_type& __a = allocator_type())
173 : _M_t(__comp, _Pair_alloc_type(__a)) { }
185 #if __cplusplus >= 201103L
194 noexcept(is_nothrow_copy_constructible<_Compare>::value)
195 : _M_t(
std::
move(__x._M_t)) { }
208 map(initializer_list<value_type> __l,
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_unique(__l.begin(), __l.end()); }
216 map(
const allocator_type& __a)
217 : _M_t(_Compare(), _Pair_alloc_type(__a)) { }
220 map(
const map& __m,
const allocator_type& __a)
221 : _M_t(__m._M_t, _Pair_alloc_type(__a)) { }
224 map(
map&& __m,
const allocator_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)) { }
230 map(initializer_list<value_type> __l,
const allocator_type& __a)
231 : _M_t(_Compare(), _Pair_alloc_type(__a))
232 { _M_t._M_insert_unique(__l.begin(), __l.end()); }
235 template<
typename _InputIterator>
236 map(_InputIterator __first, _InputIterator __last,
237 const allocator_type& __a)
238 : _M_t(_Compare(), _Pair_alloc_type(__a))
239 { _M_t._M_insert_unique(__first, __last); }
252 template<
typename _InputIterator>
253 map(_InputIterator __first, _InputIterator __last)
255 { _M_t._M_insert_unique(__first, __last); }
269 template<
typename _InputIterator>
270 map(_InputIterator __first, _InputIterator __last,
271 const _Compare& __comp,
272 const allocator_type& __a = allocator_type())
273 : _M_t(__comp, _Pair_alloc_type(__a))
274 { _M_t._M_insert_unique(__first, __last); }
299 #if __cplusplus >= 201103L
318 _M_t._M_assign_unique(__l.begin(), __l.end());
326 {
return allocator_type(_M_t.get_allocator()); }
336 {
return _M_t.begin(); }
345 {
return _M_t.begin(); }
354 {
return _M_t.end(); }
362 end() const _GLIBCXX_NOEXCEPT
363 {
return _M_t.end(); }
372 {
return _M_t.rbegin(); }
379 const_reverse_iterator
381 {
return _M_t.rbegin(); }
390 {
return _M_t.rend(); }
397 const_reverse_iterator
399 {
return _M_t.rend(); }
401 #if __cplusplus >= 201103L
409 {
return _M_t.begin(); }
418 {
return _M_t.end(); }
425 const_reverse_iterator
427 {
return _M_t.rbegin(); }
434 const_reverse_iterator
436 {
return _M_t.rend(); }
445 {
return _M_t.empty(); }
450 {
return _M_t.size(); }
455 {
return _M_t.max_size(); }
474 __glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
479 #if __cplusplus >= 201103L
481 std::tuple<const key_type&>(__k),
484 __i =
insert(__i, value_type(__k, mapped_type()));
486 return (*__i).second;
489 #if __cplusplus >= 201103L
494 __glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
502 return (*__i).second;
516 at(
const key_type& __k)
520 __throw_out_of_range(__N(
"map::at"));
521 return (*__i).second;
525 at(
const key_type& __k)
const
529 __throw_out_of_range(__N(
"map::at"));
530 return (*__i).second;
534 #if __cplusplus >= 201103L
553 template<
typename... _Args>
556 {
return _M_t._M_emplace_unique(std::forward<_Args>(__args)...); }
583 template<
typename... _Args>
587 return _M_t._M_emplace_hint_unique(__pos,
588 std::forward<_Args>(__args)...);
610 {
return _M_t._M_insert_unique(__x); }
612 #if __cplusplus >= 201103L
613 template<
typename _Pair,
typename =
typename
614 std::enable_if<std::is_constructible<value_type,
615 _Pair&&>::value>::type>
618 {
return _M_t._M_insert_unique(std::forward<_Pair>(__x)); }
621 #if __cplusplus >= 201103L
630 insert(std::initializer_list<value_type> __list)
631 {
insert(__list.begin(), __list.end()); }
658 #if __cplusplus >= 201103L
659 insert(const_iterator __position,
const value_type& __x)
661 insert(iterator __position,
const value_type& __x)
663 {
return _M_t._M_insert_unique_(__position, __x); }
665 #if __cplusplus >= 201103L
666 template<
typename _Pair,
typename =
typename
667 std::enable_if<std::is_constructible<value_type,
668 _Pair&&>::value>::type>
670 insert(const_iterator __position, _Pair&& __x)
671 {
return _M_t._M_insert_unique_(__position,
672 std::forward<_Pair>(__x)); }
683 template<
typename _InputIterator>
685 insert(_InputIterator __first, _InputIterator __last)
686 { _M_t._M_insert_unique(__first, __last); }
688 #if __cplusplus >= 201103L
706 {
return _M_t.erase(__position); }
709 _GLIBCXX_ABI_TAG_CXX11
711 erase(iterator __position)
712 {
return _M_t.erase(__position); }
725 erase(iterator __position)
726 { _M_t.erase(__position); }
742 {
return _M_t.erase(__x); }
744 #if __cplusplus >= 201103L
761 erase(const_iterator __first, const_iterator __last)
762 {
return _M_t.erase(__first, __last); }
777 erase(iterator __first, iterator __last)
778 { _M_t.erase(__first, __last); }
794 #if __cplusplus >= 201103L
795 noexcept(_Alloc_traits::_S_nothrow_swap())
797 { _M_t.swap(__x._M_t); }
816 {
return _M_t.key_comp(); }
824 {
return value_compare(_M_t.key_comp()); }
843 {
return _M_t.find(__x); }
845 #if __cplusplus > 201103L
846 template<
typename _Kt>
848 find(
const _Kt& __x) -> decltype(_M_t._M_find_tr(__x))
849 {
return _M_t._M_find_tr(__x); }
867 find(
const key_type& __x)
const
868 {
return _M_t.find(__x); }
870 #if __cplusplus > 201103L
871 template<
typename _Kt>
873 find(
const _Kt& __x)
const -> decltype(_M_t._M_find_tr(__x))
874 {
return _M_t._M_find_tr(__x); }
889 {
return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
891 #if __cplusplus > 201103L
892 template<
typename _Kt>
894 count(
const _Kt& __x)
const -> decltype(_M_t._M_count_tr(__x))
895 {
return _M_t._M_find_tr(__x) == _M_t.end() ? 0 : 1; }
913 {
return _M_t.lower_bound(__x); }
915 #if __cplusplus > 201103L
916 template<
typename _Kt>
919 -> decltype(_M_t._M_lower_bound_tr(__x))
920 {
return _M_t._M_lower_bound_tr(__x); }
938 {
return _M_t.lower_bound(__x); }
940 #if __cplusplus > 201103L
941 template<
typename _Kt>
944 -> decltype(_M_t._M_lower_bound_tr(__x))
945 {
return _M_t._M_lower_bound_tr(__x); }
958 {
return _M_t.upper_bound(__x); }
960 #if __cplusplus > 201103L
961 template<
typename _Kt>
964 -> decltype(_M_t._M_upper_bound_tr(__x))
965 {
return _M_t._M_upper_bound_tr(__x); }
978 {
return _M_t.upper_bound(__x); }
980 #if __cplusplus > 201103L
981 template<
typename _Kt>
984 -> decltype(_M_t._M_upper_bound_tr(__x))
985 {
return _M_t._M_upper_bound_tr(__x); }
1007 {
return _M_t.equal_range(__x); }
1009 #if __cplusplus > 201103L
1010 template<
typename _Kt>
1013 -> decltype(_M_t._M_equal_range_tr(__x))
1014 {
return _M_t._M_equal_range_tr(__x); }
1036 {
return _M_t.equal_range(__x); }
1038 #if __cplusplus > 201103L
1039 template<
typename _Kt>
1042 -> decltype(_M_t._M_equal_range_tr(__x))
1043 {
return _M_t._M_equal_range_tr(__x); }
1047 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
1050 const map<_K1, _T1, _C1, _A1>&);
1052 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
1054 operator<(const map<_K1, _T1, _C1, _A1>&,
1055 const map<_K1, _T1, _C1, _A1>&);
1068 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1072 {
return __x._M_t == __y._M_t; }
1085 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1087 operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x,
1089 {
return __x._M_t < __y._M_t; }
1092 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1096 {
return !(__x == __y); }
1099 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1103 {
return __y < __x; }
1106 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1108 operator<=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
1110 {
return !(__y < __x); }
1113 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1117 {
return !(__x < __y); }
1120 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1126 _GLIBCXX_END_NAMESPACE_CONTAINER
const_iterator end() const noexcept
iterator find(const key_type &__x)
Tries to locate an element in a map.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert a std::pair into the map.
bool operator==(const map< _Key, _Tp, _Compare, _Alloc > &__x, const map< _Key, _Tp, _Compare, _Alloc > &__y)
Map equality comparison.
map & operator=(initializer_list< value_type > __l)
Map list assignment operator.
map(initializer_list< value_type > __l, const allocator_type &__a)
Allocator-extended initialier-list constructor.
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
Uniform interface to C++98 and C++0x allocators.
map(const allocator_type &__a)
Allocator-extended default constructor.
A standard container made up of (key,value) pairs, which can be retrieved based on a key...
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
bool operator>=(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string doesn't precede string.
map(const map &__m, const allocator_type &__a)
Allocator-extended copy constructor.
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
const_reverse_iterator rbegin() const noexcept
void insert(std::initializer_list< value_type > __list)
Attempts to insert a list of std::pairs into the map.
constexpr piecewise_construct_t piecewise_construct
piecewise_construct
bool operator!=(const map< _Key, _Tp, _Compare, _Alloc > &__x, const map< _Key, _Tp, _Compare, _Alloc > &__y)
Based on operator==.
_T1 first
second_type is the second bound type
value_compare value_comp() const
size_type count(const key_type &__x) const
Finds the number of elements with given key.
bool operator>(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string follows string.
map()
Default constructor creates no elements.
const_iterator cbegin() const noexcept
const_iterator cend() const noexcept
iterator emplace_hint(const_iterator __pos, _Args &&...__args)
Attempts to build and insert a std::pair into the map.
map & operator=(const map &__x)
Map assignment operator.
const_reverse_iterator crend() const noexcept
std::pair< iterator, bool > emplace(_Args &&...__args)
Attempts to build and insert a std::pair into the map.
mapped_type & at(const key_type &__k)
Access to map data.
const_reverse_iterator rend() const noexcept
const_iterator find(const key_type &__x) const
Tries to locate an element in a map.
iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a map.
const_iterator begin() const noexcept
reverse_iterator rbegin() noexcept
reverse_iterator rend() noexcept
bool empty() const noexcept
iterator begin() noexcept
map(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a map with no elements.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
map(_InputIterator __first, _InputIterator __last)
Builds a map from a range.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
map(_InputIterator __first, _InputIterator __last, const allocator_type &__a)
Allocator-extended range constructor.
const_reverse_iterator crbegin() const noexcept
key_compare key_comp() const
iterator erase(const_iterator __position)
Erases an element from a map.
map(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a map from a range.
void swap(map &__x) noexcept(_Alloc_traits::_S_nothrow_swap())
Swaps data with another map.
void insert(_InputIterator __first, _InputIterator __last)
Template function that attempts to insert a range of elements.
Struct holding two objects of arbitrary type.
map(map &&__x) noexcept(is_nothrow_copy_constructible< _Compare >::value)
Map move constructor.
map(initializer_list< value_type > __l, const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())
Builds a map from an initializer_list.
size_type max_size() const noexcept
iterator insert(const_iterator __position, const value_type &__x)
Attempts to insert a std::pair into the map.
map(map &&__m, const allocator_type &__a) noexcept(is_nothrow_copy_constructible< _Compare >::value &&_Alloc_traits::_S_always_equal())
Allocator-extended move constructor.
ISO C++ entities toplevel namespace is std.
mapped_type & operator[](const key_type &__k)
Subscript ( [] ) access to map data.
map(const map &__x)
Map copy constructor.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
size_type size() const noexcept