61 #if __cplusplus >= 201103L 66 namespace std _GLIBCXX_VISIBILITY(default)
68 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
70 template <
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
97 template <
typename _Key,
typename _Tp,
typename _Compare = std::less<_Key>,
98 typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
102 typedef _Key key_type;
103 typedef _Tp mapped_type;
105 typedef _Compare key_compare;
106 typedef _Alloc allocator_type;
110 typedef typename _Alloc::value_type _Alloc_value_type;
111 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
112 __glibcxx_class_requires4(_Compare,
bool, _Key, _Key,
113 _BinaryFunctionConcept)
114 __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept)
120 friend class map<_Key, _Tp, _Compare, _Alloc>;
124 value_compare(_Compare __c)
128 bool operator()(
const value_type& __x,
const value_type& __y)
const 135 rebind<value_type>::other _Pair_alloc_type;
137 typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
138 key_compare, _Pair_alloc_type> _Rep_type;
148 typedef typename _Alloc_traits::pointer pointer;
149 typedef typename _Alloc_traits::const_pointer const_pointer;
150 typedef typename _Alloc_traits::reference reference;
151 typedef typename _Alloc_traits::const_reference const_reference;
152 typedef typename _Rep_type::iterator iterator;
153 typedef typename _Rep_type::const_iterator const_iterator;
154 typedef typename _Rep_type::size_type size_type;
155 typedef typename _Rep_type::difference_type difference_type;
159 #if __cplusplus > 201402L 160 using node_type =
typename _Rep_type::node_type;
161 using insert_return_type =
typename _Rep_type::insert_return_type;
170 #if __cplusplus < 201103L 182 map(
const _Compare& __comp,
183 const allocator_type& __a = allocator_type())
184 : _M_t(__comp, _Pair_alloc_type(__a)) { }
191 #if __cplusplus < 201103L 195 map(
const map&) =
default;
217 const _Compare& __comp = _Compare(),
218 const allocator_type& __a = allocator_type())
219 : _M_t(__comp, _Pair_alloc_type(__a))
220 { _M_t._M_insert_unique(__l.begin(), __l.end()); }
224 map(
const allocator_type& __a)
225 : _M_t(_Compare(), _Pair_alloc_type(__a)) { }
228 map(
const map& __m,
const allocator_type& __a)
229 : _M_t(__m._M_t, _Pair_alloc_type(__a)) { }
232 map(
map&& __m,
const allocator_type& __a)
233 noexcept(is_nothrow_copy_constructible<_Compare>::value
234 && _Alloc_traits::_S_always_equal())
235 : _M_t(
std::move(__m._M_t), _Pair_alloc_type(__a)) { }
239 : _M_t(_Compare(), _Pair_alloc_type(__a))
240 { _M_t._M_insert_unique(__l.begin(), __l.end()); }
243 template<
typename _InputIterator>
244 map(_InputIterator __first, _InputIterator __last,
245 const allocator_type& __a)
246 : _M_t(_Compare(), _Pair_alloc_type(__a))
247 { _M_t._M_insert_unique(__first, __last); }
260 template<
typename _InputIterator>
261 map(_InputIterator __first, _InputIterator __last)
263 { _M_t._M_insert_unique(__first, __last); }
277 template<
typename _InputIterator>
278 map(_InputIterator __first, _InputIterator __last,
279 const _Compare& __comp,
280 const allocator_type& __a = allocator_type())
281 : _M_t(__comp, _Pair_alloc_type(__a))
282 { _M_t._M_insert_unique(__first, __last); }
284 #if __cplusplus >= 201103L 298 #if __cplusplus < 201103L 327 _M_t._M_assign_unique(__l.begin(), __l.end());
335 {
return allocator_type(_M_t.get_allocator()); }
345 {
return _M_t.begin(); }
354 {
return _M_t.begin(); }
363 {
return _M_t.end(); }
371 end() const _GLIBCXX_NOEXCEPT
372 {
return _M_t.end(); }
381 {
return _M_t.rbegin(); }
388 const_reverse_iterator
390 {
return _M_t.rbegin(); }
399 {
return _M_t.rend(); }
406 const_reverse_iterator
408 {
return _M_t.rend(); }
410 #if __cplusplus >= 201103L 418 {
return _M_t.begin(); }
427 {
return _M_t.end(); }
434 const_reverse_iterator
436 {
return _M_t.rbegin(); }
443 const_reverse_iterator
445 {
return _M_t.rend(); }
454 {
return _M_t.empty(); }
459 {
return _M_t.size(); }
464 {
return _M_t.max_size(); }
483 __glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
488 #if __cplusplus >= 201103L 493 __i =
insert(__i, value_type(__k, mapped_type()));
495 return (*__i).second;
498 #if __cplusplus >= 201103L 503 __glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
509 std::forward_as_tuple(std::move(__k)),
511 return (*__i).second;
525 at(
const key_type& __k)
529 __throw_out_of_range(__N(
"map::at"));
530 return (*__i).second;
534 at(
const key_type& __k)
const 538 __throw_out_of_range(__N(
"map::at"));
539 return (*__i).second;
543 #if __cplusplus >= 201103L 562 template<
typename... _Args>
565 {
return _M_t._M_emplace_unique(std::forward<_Args>(__args)...); }
592 template<
typename... _Args>
596 return _M_t._M_emplace_hint_unique(__pos,
597 std::forward<_Args>(__args)...);
601 #if __cplusplus > 201402L 604 extract(const_iterator __pos)
606 __glibcxx_assert(__pos !=
end());
607 return _M_t.extract(__pos);
612 extract(
const key_type& __x)
613 {
return _M_t.extract(__x); }
618 {
return _M_t._M_reinsert_node_unique(std::move(__nh)); }
622 insert(const_iterator __hint, node_type&& __nh)
623 {
return _M_t._M_reinsert_node_hint_unique(__hint, std::move(__nh)); }
625 template<
typename,
typename>
626 friend class _Rb_tree_merge_helper;
628 template<
typename _C2>
632 using _Merge_helper = _Rb_tree_merge_helper<map, _C2>;
633 _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source));
636 template<
typename _C2>
641 template<
typename _C2>
645 using _Merge_helper = _Rb_tree_merge_helper<map, _C2>;
646 _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source));
649 template<
typename _C2>
655 #if __cplusplus > 201402L 656 #define __cpp_lib_map_try_emplace 201411 677 template <
typename... _Args>
679 try_emplace(
const key_type& __k, _Args&&... __args)
685 std::forward_as_tuple(__k),
686 std::forward_as_tuple(
687 std::forward<_Args>(__args)...));
694 template <
typename... _Args>
696 try_emplace(key_type&& __k, _Args&&... __args)
702 std::forward_as_tuple(std::move(__k)),
703 std::forward_as_tuple(
704 std::forward<_Args>(__args)...));
737 template <
typename... _Args>
739 try_emplace(const_iterator __hint,
const key_type& __k,
743 auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k);
744 if (__true_hint.second)
747 std::forward_as_tuple(__k),
748 std::forward_as_tuple(
749 std::forward<_Args>(__args)...));
751 __i = iterator(__true_hint.first);
756 template <
typename... _Args>
758 try_emplace(const_iterator __hint, key_type&& __k, _Args&&... __args)
761 auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k);
762 if (__true_hint.second)
765 std::forward_as_tuple(std::move(__k)),
766 std::forward_as_tuple(
767 std::forward<_Args>(__args)...));
769 __i = iterator(__true_hint.first);
792 {
return _M_t._M_insert_unique(__x); }
794 #if __cplusplus >= 201103L 795 template<
typename _Pair,
typename =
typename 796 std::enable_if<std::is_constructible<value_type,
797 _Pair&&>::value>::type>
800 {
return _M_t._M_insert_unique(std::forward<_Pair>(__x)); }
803 #if __cplusplus >= 201103L 813 {
insert(__list.begin(), __list.end()); }
840 #if __cplusplus >= 201103L 841 insert(const_iterator __position,
const value_type& __x)
843 insert(iterator __position,
const value_type& __x)
845 {
return _M_t._M_insert_unique_(__position, __x); }
847 #if __cplusplus >= 201103L 848 template<
typename _Pair,
typename =
typename 849 std::enable_if<std::is_constructible<value_type,
850 _Pair&&>::value>::type>
852 insert(const_iterator __position, _Pair&& __x)
853 {
return _M_t._M_insert_unique_(__position,
854 std::forward<_Pair>(__x)); }
865 template<
typename _InputIterator>
867 insert(_InputIterator __first, _InputIterator __last)
868 { _M_t._M_insert_unique(__first, __last); }
870 #if __cplusplus > 201402L 871 #define __cpp_lib_map_insertion 201411 891 template <
typename _Obj>
893 insert_or_assign(
const key_type& __k, _Obj&& __obj)
899 std::forward_as_tuple(__k),
900 std::forward_as_tuple(
901 std::forward<_Obj>(__obj)));
904 (*__i).second = std::forward<_Obj>(__obj);
909 template <
typename _Obj>
911 insert_or_assign(key_type&& __k, _Obj&& __obj)
917 std::forward_as_tuple(std::move(__k)),
918 std::forward_as_tuple(
919 std::forward<_Obj>(__obj)));
922 (*__i).second = std::forward<_Obj>(__obj);
946 template <
typename _Obj>
948 insert_or_assign(const_iterator __hint,
949 const key_type& __k, _Obj&& __obj)
952 auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k);
953 if (__true_hint.second)
957 std::forward_as_tuple(__k),
958 std::forward_as_tuple(
959 std::forward<_Obj>(__obj)));
961 __i = iterator(__true_hint.first);
962 (*__i).second = std::forward<_Obj>(__obj);
967 template <
typename _Obj>
969 insert_or_assign(const_iterator __hint, key_type&& __k, _Obj&& __obj)
972 auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k);
973 if (__true_hint.second)
977 std::forward_as_tuple(std::move(__k)),
978 std::forward_as_tuple(
979 std::forward<_Obj>(__obj)));
981 __i = iterator(__true_hint.first);
982 (*__i).second = std::forward<_Obj>(__obj);
987 #if __cplusplus >= 201103L 1007 {
return _M_t.erase(__position); }
1010 _GLIBCXX_ABI_TAG_CXX11
1013 {
return _M_t.erase(__position); }
1027 erase(iterator __position)
1028 { _M_t.erase(__position); }
1044 {
return _M_t.erase(__x); }
1046 #if __cplusplus >= 201103L 1063 erase(const_iterator __first, const_iterator __last)
1064 {
return _M_t.erase(__first, __last); }
1079 erase(iterator __first, iterator __last)
1080 { _M_t.erase(__first, __last); }
1098 _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
1099 { _M_t.swap(__x._M_t); }
1118 {
return _M_t.key_comp(); }
1126 {
return value_compare(_M_t.key_comp()); }
1145 {
return _M_t.find(__x); }
1147 #if __cplusplus > 201103L 1148 template<
typename _Kt>
1150 find(
const _Kt& __x) -> decltype(_M_t._M_find_tr(__x))
1151 {
return _M_t._M_find_tr(__x); }
1170 {
return _M_t.find(__x); }
1172 #if __cplusplus > 201103L 1173 template<
typename _Kt>
1175 find(
const _Kt& __x)
const -> decltype(_M_t._M_find_tr(__x))
1176 {
return _M_t._M_find_tr(__x); }
1191 {
return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
1193 #if __cplusplus > 201103L 1194 template<
typename _Kt>
1196 count(
const _Kt& __x)
const -> decltype(_M_t._M_count_tr(__x))
1197 {
return _M_t._M_count_tr(__x); }
1215 {
return _M_t.lower_bound(__x); }
1217 #if __cplusplus > 201103L 1218 template<
typename _Kt>
1221 -> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
1222 {
return iterator(_M_t._M_lower_bound_tr(__x)); }
1240 {
return _M_t.lower_bound(__x); }
1242 #if __cplusplus > 201103L 1243 template<
typename _Kt>
1246 -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x)))
1247 {
return const_iterator(_M_t._M_lower_bound_tr(__x)); }
1260 {
return _M_t.upper_bound(__x); }
1262 #if __cplusplus > 201103L 1263 template<
typename _Kt>
1266 -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
1267 {
return iterator(_M_t._M_upper_bound_tr(__x)); }
1280 {
return _M_t.upper_bound(__x); }
1282 #if __cplusplus > 201103L 1283 template<
typename _Kt>
1286 -> decltype(const_iterator(_M_t._M_upper_bound_tr(__x)))
1287 {
return const_iterator(_M_t._M_upper_bound_tr(__x)); }
1309 {
return _M_t.equal_range(__x); }
1311 #if __cplusplus > 201103L 1312 template<
typename _Kt>
1338 {
return _M_t.equal_range(__x); }
1340 #if __cplusplus > 201103L 1341 template<
typename _Kt>
1345 _M_t._M_equal_range_tr(__x)))
1348 _M_t._M_equal_range_tr(__x));
1353 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
1358 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
1360 operator<(const map<_K1, _T1, _C1, _A1>&,
1374 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1378 {
return __x._M_t == __y._M_t; }
1391 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1393 operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x,
1395 {
return __x._M_t < __y._M_t; }
1398 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1402 {
return !(__x == __y); }
1405 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1409 {
return __y < __x; }
1412 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1414 operator<=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
1416 {
return !(__y < __x); }
1419 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1423 {
return !(__x < __y); }
1426 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1430 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
1433 _GLIBCXX_END_NAMESPACE_CONTAINER
1435 #if __cplusplus > 201402L 1436 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1438 template<
typename _Key,
typename _Val,
typename _Cmp1,
typename _Alloc,
1441 _Rb_tree_merge_helper<_GLIBCXX_STD_C::map<_Key, _Val, _Cmp1, _Alloc>,
1445 friend class _GLIBCXX_STD_C::map<_Key, _Val, _Cmp1, _Alloc>;
1448 _S_get_tree(_GLIBCXX_STD_C::map<_Key, _Val, _Cmp2, _Alloc>& __map)
1449 {
return __map._M_t; }
1452 _S_get_tree(_GLIBCXX_STD_C::multimap<_Key, _Val, _Cmp2, _Alloc>& __map)
1453 {
return __map._M_t; }
1455 _GLIBCXX_END_NAMESPACE_VERSION
auto find(const _Kt &__x) -> decltype(_M_t._M_find_tr(__x))
Tries to locate an element in a map.
const_reverse_iterator crbegin() const noexcept
size_type erase(const key_type &__x)
Erases elements according to the provided key.
bool operator!=(const map< _Key, _Tp, _Compare, _Alloc > &__x, const map< _Key, _Tp, _Compare, _Alloc > &__y)
Based on operator==.
const_iterator cbegin() const noexcept
Primary class template, tuple.
size_type size() const noexcept
map(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a map from a range.
size_type max_size() const noexcept
reverse_iterator rbegin() noexcept
map(map &&__m, const allocator_type &__a) noexcept(is_nothrow_copy_constructible< _Compare >::value &&_Alloc_traits::_S_always_equal())
Allocator-extended move constructor.
void insert(std::initializer_list< value_type > __list)
Attempts to insert a list of std::pairs into the map.
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.
map()=default
Default constructor creates no elements.
map & operator=(const map &)=default
Map assignment operator.
value_compare value_comp() const
map(initializer_list< value_type > __l, const allocator_type &__a)
Allocator-extended initialier-list constructor.
iterator emplace_hint(const_iterator __pos, _Args &&... __args)
Attempts to build and insert a std::pair into the map.
map & operator=(initializer_list< value_type > __l)
Map list assignment operator.
iterator erase(const_iterator __position)
Erases an element from a map.
ISO C++ entities toplevel namespace is std.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
auto lower_bound(const _Kt &__x) -> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
Finds the beginning of a subsequence matching given key.
auto find(const _Kt &__x) const -> decltype(_M_t._M_find_tr(__x))
Tries to locate an element in a map.
const_reverse_iterator rend() const noexcept
bool operator==(const map< _Key, _Tp, _Compare, _Alloc > &__x, const map< _Key, _Tp, _Compare, _Alloc > &__y)
Map equality comparison.
size_type count(const key_type &__x) const
Finds the number of elements with given key.
reverse_iterator rend() noexcept
auto count(const _Kt &__x) const -> decltype(_M_t._M_count_tr(__x))
Finds the number of elements with given key.
A standard container made up of (key,value) pairs, which can be retrieved based on a key...
bool empty() const noexcept
iterator insert(const_iterator __position, const value_type &__x)
Attempts to insert a std::pair into the map.
const_iterator lower_bound(const key_type &__x) const
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.
const_iterator cend() const noexcept
map(initializer_list< value_type > __l, const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())
Builds a map from an initializer_list.
const_reverse_iterator crend() const noexcept
_GLIBCXX_ABI_TAG_CXX11 iterator erase(iterator __position)
Erases an element from a map.
const_iterator begin() const noexcept
void swap(map &__x) noexcept(/*conditional */)
Swaps data with another map.
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
constexpr piecewise_construct_t piecewise_construct
piecewise_construct
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)
Based on operator<.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert a std::pair into the map.
key_compare key_comp() const
map(const allocator_type &__a)
Allocator-extended default constructor.
void insert(_InputIterator __first, _InputIterator __last)
Template function that attempts to insert a range of elements.
std::pair< iterator, bool > emplace(_Args &&... __args)
Attempts to build and insert a std::pair into the map.
map(_InputIterator __first, _InputIterator __last, const allocator_type &__a)
Allocator-extended range constructor.
auto equal_range(const _Kt &__x) -> decltype(pair< iterator, iterator >(_M_t._M_equal_range_tr(__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<.
iterator begin() noexcept
_T1 first
second_type is the second bound type
iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a map.
A standard container made up of (key,value) pairs, which can be retrieved based on a key...
map(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a map with no elements.
auto upper_bound(const _Kt &__x) -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
Finds the end of a subsequence matching given key.
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
mapped_type & at(const key_type &__k)
Access to map data.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
Struct holding two objects of arbitrary type.
map(_InputIterator __first, _InputIterator __last)
Builds a map from a range.
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.
const_reverse_iterator rbegin() const noexcept
const_iterator end() const noexcept
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.
Uniform interface to C++98 and C++11 allocators.
const_iterator find(const key_type &__x) const
Tries to locate an element in a map.
iterator find(const key_type &__x)
Tries to locate an element in a map.
mapped_type & operator[](const key_type &__k)
Subscript ( [] ) access to map data.