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
165 && is_nothrow_default_constructible<key_compare>::value)
175 map(
const _Compare& __comp,
176 const allocator_type& __a = allocator_type())
177 : _M_t(__comp, _Pair_alloc_type(__a)) { }
189 #if __cplusplus >= 201103L 198 noexcept(is_nothrow_copy_constructible<_Compare>::value)
199 : _M_t(
std::move(__x._M_t)) { }
213 const _Compare& __comp = _Compare(),
214 const allocator_type& __a = allocator_type())
215 : _M_t(__comp, _Pair_alloc_type(__a))
216 { _M_t._M_insert_unique(__l.begin(), __l.end()); }
220 map(
const allocator_type& __a)
221 : _M_t(_Compare(), _Pair_alloc_type(__a)) { }
224 map(
const map& __m,
const allocator_type& __a)
225 : _M_t(__m._M_t, _Pair_alloc_type(__a)) { }
228 map(
map&& __m,
const allocator_type& __a)
229 noexcept(is_nothrow_copy_constructible<_Compare>::value
230 && _Alloc_traits::_S_always_equal())
231 : _M_t(
std::move(__m._M_t), _Pair_alloc_type(__a)) { }
235 : _M_t(_Compare(), _Pair_alloc_type(__a))
236 { _M_t._M_insert_unique(__l.begin(), __l.end()); }
239 template<
typename _InputIterator>
240 map(_InputIterator __first, _InputIterator __last,
241 const allocator_type& __a)
242 : _M_t(_Compare(), _Pair_alloc_type(__a))
243 { _M_t._M_insert_unique(__first, __last); }
256 template<
typename _InputIterator>
257 map(_InputIterator __first, _InputIterator __last)
259 { _M_t._M_insert_unique(__first, __last); }
273 template<
typename _InputIterator>
274 map(_InputIterator __first, _InputIterator __last,
275 const _Compare& __comp,
276 const allocator_type& __a = allocator_type())
277 : _M_t(__comp, _Pair_alloc_type(__a))
278 { _M_t._M_insert_unique(__first, __last); }
303 #if __cplusplus >= 201103L 322 _M_t._M_assign_unique(__l.begin(), __l.end());
330 {
return allocator_type(_M_t.get_allocator()); }
340 {
return _M_t.begin(); }
349 {
return _M_t.begin(); }
358 {
return _M_t.end(); }
366 end() const _GLIBCXX_NOEXCEPT
367 {
return _M_t.end(); }
376 {
return _M_t.rbegin(); }
383 const_reverse_iterator
385 {
return _M_t.rbegin(); }
394 {
return _M_t.rend(); }
401 const_reverse_iterator
403 {
return _M_t.rend(); }
405 #if __cplusplus >= 201103L 413 {
return _M_t.begin(); }
422 {
return _M_t.end(); }
429 const_reverse_iterator
431 {
return _M_t.rbegin(); }
438 const_reverse_iterator
440 {
return _M_t.rend(); }
449 {
return _M_t.empty(); }
454 {
return _M_t.size(); }
459 {
return _M_t.max_size(); }
478 __glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
483 #if __cplusplus >= 201103L 488 __i =
insert(__i, value_type(__k, mapped_type()));
490 return (*__i).second;
493 #if __cplusplus >= 201103L 498 __glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
504 std::forward_as_tuple(std::move(__k)),
506 return (*__i).second;
520 at(
const key_type& __k)
524 __throw_out_of_range(__N(
"map::at"));
525 return (*__i).second;
529 at(
const key_type& __k)
const 533 __throw_out_of_range(__N(
"map::at"));
534 return (*__i).second;
538 #if __cplusplus >= 201103L 557 template<
typename... _Args>
560 {
return _M_t._M_emplace_unique(std::forward<_Args>(__args)...); }
587 template<
typename... _Args>
591 return _M_t._M_emplace_hint_unique(__pos,
592 std::forward<_Args>(__args)...);
614 {
return _M_t._M_insert_unique(__x); }
616 #if __cplusplus >= 201103L 617 template<
typename _Pair,
typename =
typename 618 std::enable_if<std::is_constructible<value_type,
619 _Pair&&>::value>::type>
622 {
return _M_t._M_insert_unique(std::forward<_Pair>(__x)); }
625 #if __cplusplus >= 201103L 635 {
insert(__list.begin(), __list.end()); }
662 #if __cplusplus >= 201103L 663 insert(const_iterator __position,
const value_type& __x)
665 insert(iterator __position,
const value_type& __x)
667 {
return _M_t._M_insert_unique_(__position, __x); }
669 #if __cplusplus >= 201103L 670 template<
typename _Pair,
typename =
typename 671 std::enable_if<std::is_constructible<value_type,
672 _Pair&&>::value>::type>
674 insert(const_iterator __position, _Pair&& __x)
675 {
return _M_t._M_insert_unique_(__position,
676 std::forward<_Pair>(__x)); }
687 template<
typename _InputIterator>
689 insert(_InputIterator __first, _InputIterator __last)
690 { _M_t._M_insert_unique(__first, __last); }
692 #if __cplusplus >= 201103L 710 {
return _M_t.erase(__position); }
713 _GLIBCXX_ABI_TAG_CXX11
715 erase(iterator __position)
716 {
return _M_t.erase(__position); }
729 erase(iterator __position)
730 { _M_t.erase(__position); }
746 {
return _M_t.erase(__x); }
748 #if __cplusplus >= 201103L 765 erase(const_iterator __first, const_iterator __last)
766 {
return _M_t.erase(__first, __last); }
781 erase(iterator __first, iterator __last)
782 { _M_t.erase(__first, __last); }
798 #if __cplusplus >= 201103L 799 noexcept(_Alloc_traits::_S_nothrow_swap())
801 { _M_t.swap(__x._M_t); }
820 {
return _M_t.key_comp(); }
828 {
return value_compare(_M_t.key_comp()); }
847 {
return _M_t.find(__x); }
849 #if __cplusplus > 201103L 850 template<
typename _Kt>
852 find(
const _Kt& __x) -> decltype(_M_t._M_find_tr(__x))
853 {
return _M_t._M_find_tr(__x); }
871 find(
const key_type& __x)
const 872 {
return _M_t.find(__x); }
874 #if __cplusplus > 201103L 875 template<
typename _Kt>
877 find(
const _Kt& __x)
const -> decltype(_M_t._M_find_tr(__x))
878 {
return _M_t._M_find_tr(__x); }
893 {
return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
895 #if __cplusplus > 201103L 896 template<
typename _Kt>
898 count(
const _Kt& __x)
const -> decltype(_M_t._M_count_tr(__x))
899 {
return _M_t._M_count_tr(__x); }
917 {
return _M_t.lower_bound(__x); }
919 #if __cplusplus > 201103L 920 template<
typename _Kt>
923 -> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
924 {
return iterator(_M_t._M_lower_bound_tr(__x)); }
942 {
return _M_t.lower_bound(__x); }
944 #if __cplusplus > 201103L 945 template<
typename _Kt>
948 -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x)))
949 {
return const_iterator(_M_t._M_lower_bound_tr(__x)); }
962 {
return _M_t.upper_bound(__x); }
964 #if __cplusplus > 201103L 965 template<
typename _Kt>
968 -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
969 {
return iterator(_M_t._M_upper_bound_tr(__x)); }
982 {
return _M_t.upper_bound(__x); }
984 #if __cplusplus > 201103L 985 template<
typename _Kt>
988 -> decltype(const_iterator(_M_t._M_upper_bound_tr(__x)))
989 {
return const_iterator(_M_t._M_upper_bound_tr(__x)); }
1011 {
return _M_t.equal_range(__x); }
1013 #if __cplusplus > 201103L 1014 template<
typename _Kt>
1040 {
return _M_t.equal_range(__x); }
1042 #if __cplusplus > 201103L 1043 template<
typename _Kt>
1047 _M_t._M_equal_range_tr(__x)))
1050 _M_t._M_equal_range_tr(__x));
1055 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
1060 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
1062 operator<(const map<_K1, _T1, _C1, _A1>&,
1076 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1080 {
return __x._M_t == __y._M_t; }
1093 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1095 operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x,
1097 {
return __x._M_t < __y._M_t; }
1100 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1104 {
return !(__x == __y); }
1107 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1111 {
return __y < __x; }
1114 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1116 operator<=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
1118 {
return !(__y < __x); }
1121 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1125 {
return !(__x < __y); }
1128 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1134 _GLIBCXX_END_NAMESPACE_CONTAINER
const_reverse_iterator rbegin() const noexcept
reverse_iterator rbegin() noexcept
map(const allocator_type &__a)
Allocator-extended default constructor.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
key_compare key_comp() const
map() noexcept(is_nothrow_default_constructible< allocator_type >::value &&is_nothrow_default_constructible< key_compare >::value)
Default constructor creates no elements.
size_type size() const noexcept
auto equal_range(const _Kt &__x) const -> decltype(pair< const_iterator, const_iterator >(_M_t._M_equal_range_tr(__x)))
Finds a subsequence matching given key.
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
auto upper_bound(const _Kt &__x) -> decltype(iterator(_M_t._M_upper_bound_tr(__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)
Based on operator==.
bool operator>=(const map< _Key, _Tp, _Compare, _Alloc > &__x, const map< _Key, _Tp, _Compare, _Alloc > &__y)
Based on operator<.
iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a map.
auto equal_range(const _Kt &__x) -> decltype(pair< iterator, iterator >(_M_t._M_equal_range_tr(__x)))
Finds a subsequence matching given key.
bool empty() const noexcept
mapped_type & at(const key_type &__k)
Access to map data.
auto upper_bound(const _Kt &__x) const -> decltype(const_iterator(_M_t._M_upper_bound_tr(__x)))
Finds the end of a subsequence matching given key.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert a std::pair into the map.
const_iterator end() const noexcept
map & operator=(const map &__x)
Map assignment operator.
void insert(std::initializer_list< value_type > __list)
Attempts to insert a list of std::pairs into the map.
iterator emplace_hint(const_iterator __pos, _Args &&... __args)
Attempts to build and insert a std::pair into the map.
size_type max_size() const noexcept
const_iterator find(const key_type &__x) const
Tries to locate an element in a map.
const_iterator cbegin() const noexcept
const_reverse_iterator rend() const noexcept
const_iterator cend() const noexcept
mapped_type & operator[](const key_type &__k)
Subscript ( [] ) access to map data.
map(const map &__x)
Map copy constructor.
iterator begin() noexcept
auto count(const _Kt &__x) const -> decltype(_M_t._M_count_tr(__x))
Finds the number of elements with given key.
Uniform interface to C++98 and C++0x allocators.
auto lower_bound(const _Kt &__x) -> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
Finds the beginning of a subsequence matching given key.
void swap(map &__x) noexcept(_Alloc_traits::_S_nothrow_swap())
Swaps data with another 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.
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.
auto find(const _Kt &__x) -> decltype(_M_t._M_find_tr(__x))
Tries to locate an element in a map.
map(_InputIterator __first, _InputIterator __last)
Builds a map from a range.
Primary class template, tuple.
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
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.
map & operator=(initializer_list< value_type > __l)
Map list assignment operator.
iterator insert(const_iterator __position, const value_type &__x)
Attempts to insert a std::pair into the map.
map(initializer_list< value_type > __l, const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())
Builds a map from an initializer_list.
constexpr piecewise_construct_t piecewise_construct
piecewise_construct
Struct holding two objects of arbitrary type.
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
map(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a map from a range.
A standard container made up of (key,value) pairs, which can be retrieved based on a key...
map(initializer_list< value_type > __l, const allocator_type &__a)
Allocator-extended initialier-list constructor.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
const_iterator begin() const noexcept
iterator lower_bound(const key_type &__x)
Finds the beginning of 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_reverse_iterator crbegin() const noexcept
map(map &&__x) noexcept(is_nothrow_copy_constructible< _Compare >::value)
Map move constructor.
std::pair< iterator, bool > emplace(_Args &&... __args)
Attempts to build and 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.
reverse_iterator rend() noexcept
iterator erase(const_iterator __position)
Erases an element from a map.
auto lower_bound(const _Kt &__x) const -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x)))
Finds the beginning of a subsequence matching given key.
const_reverse_iterator crend() const noexcept
auto find(const _Kt &__x) const -> decltype(_M_t._M_find_tr(__x))
Tries to locate an element in a map.
value_compare value_comp() const
map(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a map with no elements.
_T1 first
second_type is the second bound type
void insert(_InputIterator __first, _InputIterator __last)
Template function that attempts to insert a range of elements.
iterator find(const key_type &__x)
Tries to locate an element in a map.
size_type count(const key_type &__x) const
Finds the number of elements with given key.