61 #if __cplusplus >= 201103L 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;
163 #if __cplusplus >= 201103L 164 noexcept(is_nothrow_default_constructible<allocator_type>::value)
174 map(
const _Compare& __comp,
175 const allocator_type& __a = allocator_type())
176 : _M_t(__comp, _Pair_alloc_type(__a)) { }
188 #if __cplusplus >= 201103L 197 noexcept(is_nothrow_copy_constructible<_Compare>::value)
198 : _M_t(
std::move(__x._M_t)) { }
212 const _Compare& __comp = _Compare(),
213 const allocator_type& __a = allocator_type())
214 : _M_t(__comp, _Pair_alloc_type(__a))
215 { _M_t._M_insert_unique(__l.begin(), __l.end()); }
219 map(
const allocator_type& __a)
220 : _M_t(_Compare(), _Pair_alloc_type(__a)) { }
223 map(
const map& __m,
const allocator_type& __a)
224 : _M_t(__m._M_t, _Pair_alloc_type(__a)) { }
227 map(
map&& __m,
const allocator_type& __a)
228 noexcept(is_nothrow_copy_constructible<_Compare>::value
229 && _Alloc_traits::_S_always_equal())
230 : _M_t(
std::move(__m._M_t), _Pair_alloc_type(__a)) { }
234 : _M_t(_Compare(), _Pair_alloc_type(__a))
235 { _M_t._M_insert_unique(__l.begin(), __l.end()); }
238 template<
typename _InputIterator>
239 map(_InputIterator __first, _InputIterator __last,
240 const allocator_type& __a)
241 : _M_t(_Compare(), _Pair_alloc_type(__a))
242 { _M_t._M_insert_unique(__first, __last); }
255 template<
typename _InputIterator>
256 map(_InputIterator __first, _InputIterator __last)
258 { _M_t._M_insert_unique(__first, __last); }
272 template<
typename _InputIterator>
273 map(_InputIterator __first, _InputIterator __last,
274 const _Compare& __comp,
275 const allocator_type& __a = allocator_type())
276 : _M_t(__comp, _Pair_alloc_type(__a))
277 { _M_t._M_insert_unique(__first, __last); }
302 #if __cplusplus >= 201103L 321 _M_t._M_assign_unique(__l.begin(), __l.end());
329 {
return allocator_type(_M_t.get_allocator()); }
339 {
return _M_t.begin(); }
348 {
return _M_t.begin(); }
357 {
return _M_t.end(); }
365 end() const _GLIBCXX_NOEXCEPT
366 {
return _M_t.end(); }
375 {
return _M_t.rbegin(); }
382 const_reverse_iterator
384 {
return _M_t.rbegin(); }
393 {
return _M_t.rend(); }
400 const_reverse_iterator
402 {
return _M_t.rend(); }
404 #if __cplusplus >= 201103L 412 {
return _M_t.begin(); }
421 {
return _M_t.end(); }
428 const_reverse_iterator
430 {
return _M_t.rbegin(); }
437 const_reverse_iterator
439 {
return _M_t.rend(); }
448 {
return _M_t.empty(); }
453 {
return _M_t.size(); }
458 {
return _M_t.max_size(); }
477 __glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
482 #if __cplusplus >= 201103L 487 __i =
insert(__i, value_type(__k, mapped_type()));
489 return (*__i).second;
492 #if __cplusplus >= 201103L 497 __glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
503 std::forward_as_tuple(
std::move(__k)),
505 return (*__i).second;
519 at(
const key_type& __k)
523 __throw_out_of_range(__N(
"map::at"));
524 return (*__i).second;
528 at(
const key_type& __k)
const 532 __throw_out_of_range(__N(
"map::at"));
533 return (*__i).second;
537 #if __cplusplus >= 201103L 556 template<
typename... _Args>
559 {
return _M_t._M_emplace_unique(std::forward<_Args>(__args)...); }
586 template<
typename... _Args>
590 return _M_t._M_emplace_hint_unique(__pos,
591 std::forward<_Args>(__args)...);
613 {
return _M_t._M_insert_unique(__x); }
615 #if __cplusplus >= 201103L 616 template<
typename _Pair,
typename =
typename 617 std::enable_if<std::is_constructible<value_type,
618 _Pair&&>::value>::type>
621 {
return _M_t._M_insert_unique(std::forward<_Pair>(__x)); }
624 #if __cplusplus >= 201103L 634 {
insert(__list.begin(), __list.end()); }
661 #if __cplusplus >= 201103L 662 insert(const_iterator __position,
const value_type& __x)
664 insert(iterator __position,
const value_type& __x)
666 {
return _M_t._M_insert_unique_(__position, __x); }
668 #if __cplusplus >= 201103L 669 template<
typename _Pair,
typename =
typename 670 std::enable_if<std::is_constructible<value_type,
671 _Pair&&>::value>::type>
673 insert(const_iterator __position, _Pair&& __x)
674 {
return _M_t._M_insert_unique_(__position,
675 std::forward<_Pair>(__x)); }
686 template<
typename _InputIterator>
688 insert(_InputIterator __first, _InputIterator __last)
689 { _M_t._M_insert_unique(__first, __last); }
691 #if __cplusplus >= 201103L 709 {
return _M_t.erase(__position); }
712 _GLIBCXX_ABI_TAG_CXX11
714 erase(iterator __position)
715 {
return _M_t.erase(__position); }
728 erase(iterator __position)
729 { _M_t.erase(__position); }
745 {
return _M_t.erase(__x); }
747 #if __cplusplus >= 201103L 764 erase(const_iterator __first, const_iterator __last)
765 {
return _M_t.erase(__first, __last); }
780 erase(iterator __first, iterator __last)
781 { _M_t.erase(__first, __last); }
797 #if __cplusplus >= 201103L 798 noexcept(_Alloc_traits::_S_nothrow_swap())
800 { _M_t.swap(__x._M_t); }
819 {
return _M_t.key_comp(); }
827 {
return value_compare(_M_t.key_comp()); }
846 {
return _M_t.find(__x); }
848 #if __cplusplus > 201103L 849 template<
typename _Kt>
851 find(
const _Kt& __x) -> decltype(_M_t._M_find_tr(__x))
852 {
return _M_t._M_find_tr(__x); }
870 find(
const key_type& __x)
const 871 {
return _M_t.find(__x); }
873 #if __cplusplus > 201103L 874 template<
typename _Kt>
876 find(
const _Kt& __x)
const -> decltype(_M_t._M_find_tr(__x))
877 {
return _M_t._M_find_tr(__x); }
892 {
return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
894 #if __cplusplus > 201103L 895 template<
typename _Kt>
897 count(
const _Kt& __x)
const -> decltype(_M_t._M_count_tr(__x))
898 {
return _M_t._M_find_tr(__x) == _M_t.end() ? 0 : 1; }
916 {
return _M_t.lower_bound(__x); }
918 #if __cplusplus > 201103L 919 template<
typename _Kt>
922 -> decltype(_M_t._M_lower_bound_tr(__x))
923 {
return _M_t._M_lower_bound_tr(__x); }
941 {
return _M_t.lower_bound(__x); }
943 #if __cplusplus > 201103L 944 template<
typename _Kt>
947 -> decltype(_M_t._M_lower_bound_tr(__x))
948 {
return _M_t._M_lower_bound_tr(__x); }
961 {
return _M_t.upper_bound(__x); }
963 #if __cplusplus > 201103L 964 template<
typename _Kt>
967 -> decltype(_M_t._M_upper_bound_tr(__x))
968 {
return _M_t._M_upper_bound_tr(__x); }
981 {
return _M_t.upper_bound(__x); }
983 #if __cplusplus > 201103L 984 template<
typename _Kt>
987 -> decltype(_M_t._M_upper_bound_tr(__x))
988 {
return _M_t._M_upper_bound_tr(__x); }
1010 {
return _M_t.equal_range(__x); }
1012 #if __cplusplus > 201103L 1013 template<
typename _Kt>
1016 -> decltype(_M_t._M_equal_range_tr(__x))
1017 {
return _M_t._M_equal_range_tr(__x); }
1039 {
return _M_t.equal_range(__x); }
1041 #if __cplusplus > 201103L 1042 template<
typename _Kt>
1045 -> decltype(_M_t._M_equal_range_tr(__x))
1046 {
return _M_t._M_equal_range_tr(__x); }
1050 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
1055 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
1057 operator<(const map<_K1, _T1, _C1, _A1>&,
1071 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1075 {
return __x._M_t == __y._M_t; }
1088 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1090 operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x,
1092 {
return __x._M_t < __y._M_t; }
1095 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1099 {
return !(__x == __y); }
1102 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1106 {
return __y < __x; }
1109 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1111 operator<=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
1113 {
return !(__y < __x); }
1116 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1120 {
return !(__x < __y); }
1123 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1129 _GLIBCXX_END_NAMESPACE_CONTAINER
bool operator!=(const map< _Key, _Tp, _Compare, _Alloc > &__x, const map< _Key, _Tp, _Compare, _Alloc > &__y)
Based on operator==.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
bool operator>=(const map< _Key, _Tp, _Compare, _Alloc > &__x, const map< _Key, _Tp, _Compare, _Alloc > &__y)
Based on operator<.
const_iterator begin() const noexcept
iterator emplace_hint(const_iterator __pos, _Args &&...__args)
Attempts to build and insert a std::pair into the map.
Primary class template, tuple.
map(initializer_list< value_type > __l, const allocator_type &__a)
Allocator-extended initialier-list constructor.
auto find(const _Kt &__x) const -> decltype(_M_t._M_find_tr(__x))
Tries to locate an element in a map.
reverse_iterator rbegin() noexcept
constexpr piecewise_construct_t piecewise_construct
piecewise_construct
reverse_iterator rend() noexcept
iterator find(const key_type &__x)
Tries to locate an element in a map.
map(map &&__m, const allocator_type &__a) noexcept(is_nothrow_copy_constructible< _Compare >::value &&_Alloc_traits::_S_always_equal())
Allocator-extended move constructor.
map & operator=(initializer_list< value_type > __l)
Map list assignment operator.
A standard container made up of (key,value) pairs, which can be retrieved based on a key...
const_iterator end() const noexcept
const_reverse_iterator rbegin() const noexcept
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
mapped_type & at(const key_type &__k)
Access to map data.
size_type count(const key_type &__x) const
Finds the number of elements with given key.
size_type max_size() const noexcept
const_iterator cend() const noexcept
map(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a map from a range.
const_reverse_iterator crbegin() const noexcept
auto equal_range(const _Kt &__x) const -> decltype(_M_t._M_equal_range_tr(__x))
Finds a subsequence matching given key.
map & operator=(const map &__x)
Map assignment operator.
mapped_type & operator[](const key_type &__k)
Subscript ( [] ) access to map data.
map() noexcept(is_nothrow_default_constructible< allocator_type >::value)
Default constructor creates no elements.
const_reverse_iterator rend() const noexcept
iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a map.
map(_InputIterator __first, _InputIterator __last)
Builds a map from a range.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert a std::pair into the map.
key_compare key_comp() const
iterator erase(const_iterator __position)
Erases an element from a map.
bool empty() const noexcept
auto upper_bound(const _Kt &__x) -> decltype(_M_t._M_upper_bound_tr(__x))
Finds the end of a subsequence matching given key.
const_iterator find(const key_type &__x) const
Tries to locate an element in a map.
auto lower_bound(const _Kt &__x) const -> decltype(_M_t._M_lower_bound_tr(__x))
Finds the beginning of a subsequence matching given key.
auto upper_bound(const _Kt &__x) const -> decltype(_M_t._M_upper_bound_tr(__x))
Finds the end of a subsequence matching given key.
const_reverse_iterator crend() const noexcept
map(_InputIterator __first, _InputIterator __last, const allocator_type &__a)
Allocator-extended range constructor.
iterator begin() noexcept
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
void swap(map &__x) noexcept(_Alloc_traits::_S_nothrow_swap())
Swaps data with another map.
std::pair< iterator, bool > emplace(_Args &&...__args)
Attempts to build and insert a std::pair into the map.
void insert(std::initializer_list< value_type > __list)
Attempts to insert a list of std::pairs into the map.
auto equal_range(const _Kt &__x) -> decltype(_M_t._M_equal_range_tr(__x))
Finds a subsequence matching given key.
size_type size() const noexcept
bool operator>(const map< _Key, _Tp, _Compare, _Alloc > &__x, const map< _Key, _Tp, _Compare, _Alloc > &__y)
Based on operator<.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
auto lower_bound(const _Kt &__x) -> decltype(_M_t._M_lower_bound_tr(__x))
Finds the beginning of a subsequence matching given key.
void insert(_InputIterator __first, _InputIterator __last)
Template function that attempts to insert a range of elements.
const_iterator cbegin() const noexcept
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
auto count(const _Kt &__x) const -> decltype(_M_t._M_count_tr(__x))
Finds the number of elements with given key.
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
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.
Struct holding two objects of arbitrary type.
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
_T1 first
second_type is the second bound type
map(const allocator_type &__a)
Allocator-extended default constructor.
ISO C++ entities toplevel namespace is std.
iterator insert(const_iterator __position, const value_type &__x)
Attempts to insert a std::pair into the map.
Uniform interface to C++98 and C++0x allocators.
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.
bool operator==(const map< _Key, _Tp, _Compare, _Alloc > &__x, const map< _Key, _Tp, _Compare, _Alloc > &__y)
Map equality comparison.
map(const map &__x)
Map copy constructor.
auto find(const _Kt &__x) -> decltype(_M_t._M_find_tr(__x))
Tries to locate an element in a map.
map(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a map with no elements.
value_compare value_comp() const