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;
109 #ifdef _GLIBCXX_CONCEPT_CHECKS 111 typedef typename _Alloc::value_type _Alloc_value_type;
112 # if __cplusplus < 201103L 113 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
115 __glibcxx_class_requires4(_Compare,
bool, _Key, _Key,
116 _BinaryFunctionConcept)
117 __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept)
124 friend class map<_Key, _Tp, _Compare, _Alloc>;
128 value_compare(_Compare __c)
132 bool operator()(
const value_type& __x,
const value_type& __y)
const 139 rebind<value_type>::other _Pair_alloc_type;
141 typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
142 key_compare, _Pair_alloc_type> _Rep_type;
152 typedef typename _Alloc_traits::pointer pointer;
153 typedef typename _Alloc_traits::const_pointer const_pointer;
154 typedef typename _Alloc_traits::reference reference;
155 typedef typename _Alloc_traits::const_reference const_reference;
156 typedef typename _Rep_type::iterator iterator;
157 typedef typename _Rep_type::const_iterator const_iterator;
158 typedef typename _Rep_type::size_type size_type;
159 typedef typename _Rep_type::difference_type difference_type;
163 #if __cplusplus > 201402L 164 using node_type =
typename _Rep_type::node_type;
165 using insert_return_type =
typename _Rep_type::insert_return_type;
174 #if __cplusplus < 201103L 186 map(
const _Compare& __comp,
187 const allocator_type& __a = allocator_type())
188 : _M_t(__comp, _Pair_alloc_type(__a)) { }
195 #if __cplusplus < 201103L 199 map(
const map&) =
default;
221 const _Compare& __comp = _Compare(),
222 const allocator_type& __a = allocator_type())
223 : _M_t(__comp, _Pair_alloc_type(__a))
224 { _M_t._M_insert_unique(__l.begin(), __l.end()); }
228 map(
const allocator_type& __a)
229 : _M_t(_Compare(), _Pair_alloc_type(__a)) { }
232 map(
const map& __m,
const allocator_type& __a)
233 : _M_t(__m._M_t, _Pair_alloc_type(__a)) { }
236 map(
map&& __m,
const allocator_type& __a)
237 noexcept(is_nothrow_copy_constructible<_Compare>::value
238 && _Alloc_traits::_S_always_equal())
239 : _M_t(
std::move(__m._M_t), _Pair_alloc_type(__a)) { }
243 : _M_t(_Compare(), _Pair_alloc_type(__a))
244 { _M_t._M_insert_unique(__l.begin(), __l.end()); }
247 template<
typename _InputIterator>
248 map(_InputIterator __first, _InputIterator __last,
249 const allocator_type& __a)
250 : _M_t(_Compare(), _Pair_alloc_type(__a))
251 { _M_t._M_insert_unique(__first, __last); }
264 template<
typename _InputIterator>
265 map(_InputIterator __first, _InputIterator __last)
267 { _M_t._M_insert_unique(__first, __last); }
281 template<
typename _InputIterator>
282 map(_InputIterator __first, _InputIterator __last,
283 const _Compare& __comp,
284 const allocator_type& __a = allocator_type())
285 : _M_t(__comp, _Pair_alloc_type(__a))
286 { _M_t._M_insert_unique(__first, __last); }
288 #if __cplusplus >= 201103L 302 #if __cplusplus < 201103L 331 _M_t._M_assign_unique(__l.begin(), __l.end());
339 {
return allocator_type(_M_t.get_allocator()); }
349 {
return _M_t.begin(); }
358 {
return _M_t.begin(); }
367 {
return _M_t.end(); }
375 end() const _GLIBCXX_NOEXCEPT
376 {
return _M_t.end(); }
385 {
return _M_t.rbegin(); }
392 const_reverse_iterator
394 {
return _M_t.rbegin(); }
403 {
return _M_t.rend(); }
410 const_reverse_iterator
412 {
return _M_t.rend(); }
414 #if __cplusplus >= 201103L 422 {
return _M_t.begin(); }
431 {
return _M_t.end(); }
438 const_reverse_iterator
440 {
return _M_t.rbegin(); }
447 const_reverse_iterator
449 {
return _M_t.rend(); }
458 {
return _M_t.empty(); }
463 {
return _M_t.size(); }
468 {
return _M_t.max_size(); }
487 __glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
492 #if __cplusplus >= 201103L 497 __i =
insert(__i, value_type(__k, mapped_type()));
499 return (*__i).second;
502 #if __cplusplus >= 201103L 507 __glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
513 std::forward_as_tuple(
std::move(__k)),
515 return (*__i).second;
529 at(
const key_type& __k)
533 __throw_out_of_range(__N(
"map::at"));
534 return (*__i).second;
538 at(
const key_type& __k)
const 542 __throw_out_of_range(__N(
"map::at"));
543 return (*__i).second;
547 #if __cplusplus >= 201103L 566 template<
typename... _Args>
569 {
return _M_t._M_emplace_unique(std::forward<_Args>(__args)...); }
596 template<
typename... _Args>
600 return _M_t._M_emplace_hint_unique(__pos,
601 std::forward<_Args>(__args)...);
605 #if __cplusplus > 201402L 608 extract(const_iterator __pos)
610 __glibcxx_assert(__pos !=
end());
611 return _M_t.extract(__pos);
616 extract(
const key_type& __x)
617 {
return _M_t.extract(__x); }
622 {
return _M_t._M_reinsert_node_unique(std::move(__nh)); }
626 insert(const_iterator __hint, node_type&& __nh)
627 {
return _M_t._M_reinsert_node_hint_unique(__hint, std::move(__nh)); }
629 template<
typename,
typename>
630 friend class _Rb_tree_merge_helper;
632 template<
typename _C2>
636 using _Merge_helper = _Rb_tree_merge_helper<map, _C2>;
637 _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source));
640 template<
typename _C2>
645 template<
typename _C2>
649 using _Merge_helper = _Rb_tree_merge_helper<map, _C2>;
650 _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source));
653 template<
typename _C2>
659 #if __cplusplus > 201402L 660 #define __cpp_lib_map_try_emplace 201411 681 template <
typename... _Args>
683 try_emplace(
const key_type& __k, _Args&&... __args)
689 std::forward_as_tuple(__k),
690 std::forward_as_tuple(
691 std::forward<_Args>(__args)...));
698 template <
typename... _Args>
700 try_emplace(key_type&& __k, _Args&&... __args)
706 std::forward_as_tuple(std::move(__k)),
707 std::forward_as_tuple(
708 std::forward<_Args>(__args)...));
741 template <
typename... _Args>
743 try_emplace(const_iterator __hint,
const key_type& __k,
747 auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k);
748 if (__true_hint.second)
751 std::forward_as_tuple(__k),
752 std::forward_as_tuple(
753 std::forward<_Args>(__args)...));
755 __i = iterator(__true_hint.first);
760 template <
typename... _Args>
762 try_emplace(const_iterator __hint, key_type&& __k, _Args&&... __args)
765 auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k);
766 if (__true_hint.second)
769 std::forward_as_tuple(std::move(__k)),
770 std::forward_as_tuple(
771 std::forward<_Args>(__args)...));
773 __i = iterator(__true_hint.first);
796 {
return _M_t._M_insert_unique(__x); }
798 #if __cplusplus >= 201103L 799 template<
typename _Pair,
typename =
typename 800 std::enable_if<std::is_constructible<value_type,
801 _Pair&&>::value>::type>
804 {
return _M_t._M_insert_unique(std::forward<_Pair>(__x)); }
807 #if __cplusplus >= 201103L 817 {
insert(__list.begin(), __list.end()); }
844 #if __cplusplus >= 201103L 845 insert(const_iterator __position,
const value_type& __x)
847 insert(iterator __position,
const value_type& __x)
849 {
return _M_t._M_insert_unique_(__position, __x); }
851 #if __cplusplus >= 201103L 852 template<
typename _Pair,
typename =
typename 853 std::enable_if<std::is_constructible<value_type,
854 _Pair&&>::value>::type>
856 insert(const_iterator __position, _Pair&& __x)
857 {
return _M_t._M_insert_unique_(__position,
858 std::forward<_Pair>(__x)); }
869 template<
typename _InputIterator>
871 insert(_InputIterator __first, _InputIterator __last)
872 { _M_t._M_insert_unique(__first, __last); }
874 #if __cplusplus > 201402L 875 #define __cpp_lib_map_insertion 201411 895 template <
typename _Obj>
897 insert_or_assign(
const key_type& __k, _Obj&& __obj)
903 std::forward_as_tuple(__k),
904 std::forward_as_tuple(
905 std::forward<_Obj>(__obj)));
908 (*__i).second = std::forward<_Obj>(__obj);
913 template <
typename _Obj>
915 insert_or_assign(key_type&& __k, _Obj&& __obj)
921 std::forward_as_tuple(std::move(__k)),
922 std::forward_as_tuple(
923 std::forward<_Obj>(__obj)));
926 (*__i).second = std::forward<_Obj>(__obj);
950 template <
typename _Obj>
952 insert_or_assign(const_iterator __hint,
953 const key_type& __k, _Obj&& __obj)
956 auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k);
957 if (__true_hint.second)
961 std::forward_as_tuple(__k),
962 std::forward_as_tuple(
963 std::forward<_Obj>(__obj)));
965 __i = iterator(__true_hint.first);
966 (*__i).second = std::forward<_Obj>(__obj);
971 template <
typename _Obj>
973 insert_or_assign(const_iterator __hint, key_type&& __k, _Obj&& __obj)
976 auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k);
977 if (__true_hint.second)
981 std::forward_as_tuple(std::move(__k)),
982 std::forward_as_tuple(
983 std::forward<_Obj>(__obj)));
985 __i = iterator(__true_hint.first);
986 (*__i).second = std::forward<_Obj>(__obj);
991 #if __cplusplus >= 201103L 1011 {
return _M_t.erase(__position); }
1014 _GLIBCXX_ABI_TAG_CXX11
1017 {
return _M_t.erase(__position); }
1031 erase(iterator __position)
1032 { _M_t.erase(__position); }
1048 {
return _M_t.erase(__x); }
1050 #if __cplusplus >= 201103L 1067 erase(const_iterator __first, const_iterator __last)
1068 {
return _M_t.erase(__first, __last); }
1083 erase(iterator __first, iterator __last)
1084 { _M_t.erase(__first, __last); }
1102 _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
1103 { _M_t.swap(__x._M_t); }
1122 {
return _M_t.key_comp(); }
1130 {
return value_compare(_M_t.key_comp()); }
1149 {
return _M_t.find(__x); }
1151 #if __cplusplus > 201103L 1152 template<
typename _Kt>
1154 find(
const _Kt& __x) -> decltype(_M_t._M_find_tr(__x))
1155 {
return _M_t._M_find_tr(__x); }
1174 {
return _M_t.find(__x); }
1176 #if __cplusplus > 201103L 1177 template<
typename _Kt>
1179 find(
const _Kt& __x)
const -> decltype(_M_t._M_find_tr(__x))
1180 {
return _M_t._M_find_tr(__x); }
1195 {
return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
1197 #if __cplusplus > 201103L 1198 template<
typename _Kt>
1200 count(
const _Kt& __x)
const -> decltype(_M_t._M_count_tr(__x))
1201 {
return _M_t._M_count_tr(__x); }
1219 {
return _M_t.lower_bound(__x); }
1221 #if __cplusplus > 201103L 1222 template<
typename _Kt>
1225 -> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
1226 {
return iterator(_M_t._M_lower_bound_tr(__x)); }
1244 {
return _M_t.lower_bound(__x); }
1246 #if __cplusplus > 201103L 1247 template<
typename _Kt>
1250 -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x)))
1251 {
return const_iterator(_M_t._M_lower_bound_tr(__x)); }
1264 {
return _M_t.upper_bound(__x); }
1266 #if __cplusplus > 201103L 1267 template<
typename _Kt>
1270 -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
1271 {
return iterator(_M_t._M_upper_bound_tr(__x)); }
1284 {
return _M_t.upper_bound(__x); }
1286 #if __cplusplus > 201103L 1287 template<
typename _Kt>
1290 -> decltype(const_iterator(_M_t._M_upper_bound_tr(__x)))
1291 {
return const_iterator(_M_t._M_upper_bound_tr(__x)); }
1313 {
return _M_t.equal_range(__x); }
1315 #if __cplusplus > 201103L 1316 template<
typename _Kt>
1342 {
return _M_t.equal_range(__x); }
1344 #if __cplusplus > 201103L 1345 template<
typename _Kt>
1349 _M_t._M_equal_range_tr(__x)))
1352 _M_t._M_equal_range_tr(__x));
1357 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
1362 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
1364 operator<(const map<_K1, _T1, _C1, _A1>&,
1378 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1382 {
return __x._M_t == __y._M_t; }
1395 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1397 operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x,
1399 {
return __x._M_t < __y._M_t; }
1402 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1406 {
return !(__x == __y); }
1409 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1413 {
return __y < __x; }
1416 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1418 operator<=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
1420 {
return !(__y < __x); }
1423 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1427 {
return !(__x < __y); }
1430 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1434 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
1437 _GLIBCXX_END_NAMESPACE_CONTAINER
1439 #if __cplusplus > 201402L 1440 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1442 template<
typename _Key,
typename _Val,
typename _Cmp1,
typename _Alloc,
1445 _Rb_tree_merge_helper<_GLIBCXX_STD_C::map<_Key, _Val, _Cmp1, _Alloc>,
1449 friend class _GLIBCXX_STD_C::map<_Key, _Val, _Cmp1, _Alloc>;
1452 _S_get_tree(_GLIBCXX_STD_C::map<_Key, _Val, _Cmp2, _Alloc>& __map)
1453 {
return __map._M_t; }
1456 _S_get_tree(_GLIBCXX_STD_C::multimap<_Key, _Val, _Cmp2, _Alloc>& __map)
1457 {
return __map._M_t; }
1459 _GLIBCXX_END_NAMESPACE_VERSION
void insert(std::initializer_list< value_type > __list)
Attempts to insert a list of std::pairs into the map.
const_reverse_iterator rend() const noexcept
map(_InputIterator __first, _InputIterator __last)
Builds a map from a range.
key_compare key_comp() const
iterator erase(const_iterator __position)
Erases an element from a map.
bool empty() const noexcept
bool operator>(const map< _Key, _Tp, _Compare, _Alloc > &__x, const map< _Key, _Tp, _Compare, _Alloc > &__y)
Based on operator<.
Uniform interface to C++98 and C++11 allocators.
auto upper_bound(const _Kt &__x) -> decltype(iterator(_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.
const_reverse_iterator crend() 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.
std::pair< iterator, bool > emplace(_Args &&...__args)
Attempts to build and insert a std::pair into the map.
_GLIBCXX17_INLINE constexpr piecewise_construct_t piecewise_construct
piecewise_construct
Primary class template, tuple.
iterator insert(const_iterator __position, const value_type &__x)
Attempts to insert a std::pair into the map.
size_type size() const noexcept
_T1 first
second_type is the second bound type
map & operator=(const map &)=default
Map assignment operator.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
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.
A standard container made up of (key,value) pairs, which can be retrieved based on a key...
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
void insert(_InputIterator __first, _InputIterator __last)
Template function that attempts to insert a range of elements.
auto equal_range(const _Kt &__x) -> decltype(pair< iterator, iterator >(_M_t._M_equal_range_tr(__x)))
Finds a subsequence matching given key.
const_iterator cbegin() const noexcept
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
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.
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.
bool operator!=(const map< _Key, _Tp, _Compare, _Alloc > &__x, const map< _Key, _Tp, _Compare, _Alloc > &__y)
Based on operator==.
ISO C++ entities toplevel namespace is std.
_GLIBCXX_ABI_TAG_CXX11 iterator erase(iterator __position)
Erases an element from a map.
bool operator>=(const map< _Key, _Tp, _Compare, _Alloc > &__x, const map< _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.
map(const allocator_type &__a)
Allocator-extended default constructor.
map()=default
Default constructor creates no elements.
map(const map &__m, const allocator_type &__a)
Allocator-extended copy constructor.
const_iterator end() const noexcept
const_reverse_iterator rbegin() const noexcept
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
value_compare value_comp() const
Struct holding two objects of arbitrary type.
size_type count(const key_type &__x) const
Finds the number of elements with given key.
size_type max_size() const noexcept
const_reverse_iterator crbegin() const noexcept
const_iterator begin() const noexcept
iterator emplace_hint(const_iterator __pos, _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.
mapped_type & operator[](const key_type &__k)
Subscript ( [] ) access to map data.
map(initializer_list< value_type > __l, const allocator_type &__a)
Allocator-extended initialier-list constructor.
iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a map.
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
reverse_iterator rend() noexcept
iterator find(const key_type &__x)
Tries to locate an element in a 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(map &&__m, const allocator_type &__a) noexcept(is_nothrow_copy_constructible< _Compare >::value &&_Alloc_traits::_S_always_equal())
Allocator-extended move constructor.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert a std::pair into the map.
map & operator=(initializer_list< value_type > __l)
Map list assignment operator.
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.
A standard container made up of (key,value) pairs, which can be retrieved based on a key...
void swap(map &__x) noexcept(/*conditional */)
Swaps data with another map.
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.
const_iterator cend() const noexcept
map(_InputIterator __first, _InputIterator __last, const allocator_type &__a)
Allocator-extended range constructor.
iterator begin() noexcept
auto lower_bound(const _Kt &__x) -> decltype(iterator(_M_t._M_lower_bound_tr(__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.
map(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a map from a range.