30#ifndef _UNORDERED_MAP_H
31#define _UNORDERED_MAP_H
38namespace std _GLIBCXX_VISIBILITY(default)
40_GLIBCXX_BEGIN_NAMESPACE_VERSION
41_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
47 template<
typename _Key,
53 using __umap_hashtable = _Hashtable<_Key, std::pair<const _Key, _Tp>,
54 _Alloc, __detail::_Select1st,
56 __detail::_Mod_range_hashing,
57 __detail::_Default_ranged_hash,
58 __detail::_Prime_rehash_policy, _Tr>;
64 template<
typename _Key,
70 using __ummap_hashtable = _Hashtable<_Key, std::pair<const _Key, _Tp>,
71 _Alloc, __detail::_Select1st,
73 __detail::_Mod_range_hashing,
74 __detail::_Default_ranged_hash,
75 __detail::_Prime_rehash_policy, _Tr>;
77 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
103 template<
typename _Key,
typename _Tp,
109 typedef __umap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Hashtable;
119 typedef typename _Hashtable::hasher
hasher;
138#if __cplusplus > 201402L
139 using node_type =
typename _Hashtable::node_type;
140 using insert_return_type =
typename _Hashtable::insert_return_type;
160 : _M_h(__n, __hf, __eql, __a)
176 template<
typename _InputIterator>
182 : _M_h(__first, __last, __n, __hf, __eql, __a)
207 : _M_h(__umap._M_h, __a)
217 noexcept(
noexcept(_Hashtable(
std::move(__umap._M_h), __a)) )
237 : _M_h(__l, __n, __hf, __eql, __a)
249 template<
typename _InputIterator>
256 template<
typename _InputIterator>
304 {
return _M_h.get_allocator(); }
309 _GLIBCXX_NODISCARD
bool
311 {
return _M_h.empty(); }
316 {
return _M_h.size(); }
321 {
return _M_h.max_size(); }
331 {
return _M_h.begin(); }
340 {
return _M_h.begin(); }
344 {
return _M_h.begin(); }
353 {
return _M_h.end(); }
362 {
return _M_h.end(); }
366 {
return _M_h.end(); }
391 template<
typename... _Args>
394 {
return _M_h.emplace(std::forward<_Args>(__args)...); }
422 template<
typename... _Args>
425 {
return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
427#if __cplusplus > 201402L
432 __glibcxx_assert(__pos !=
end());
433 return _M_h.extract(__pos);
439 {
return _M_h.extract(__key); }
444 {
return _M_h._M_reinsert_node(
std::move(__nh)); }
449 {
return _M_h._M_reinsert_node(
std::move(__nh)).position; }
451#define __cpp_lib_unordered_map_try_emplace 201411L
474 template <
typename... _Args>
478 return _M_h.try_emplace(
cend(), __k, std::forward<_Args>(__args)...);
482 template <
typename... _Args>
487 std::forward<_Args>(__args)...);
518 template <
typename... _Args>
523 return _M_h.try_emplace(__hint, __k,
524 std::forward<_Args>(__args)...).first;
528 template <
typename... _Args>
532 return _M_h.try_emplace(__hint,
std::move(__k),
533 std::forward<_Args>(__args)...).first;
557 {
return _M_h.insert(__x); }
565 template<
typename _Pair>
566 __enable_if_t<is_constructible<value_type, _Pair&&>::value,
569 {
return _M_h.emplace(std::forward<_Pair>(__x)); }
596 {
return _M_h.insert(__hint, __x); }
602 {
return _M_h.insert(__hint,
std::move(__x)); }
604 template<
typename _Pair>
605 __enable_if_t<is_constructible<value_type, _Pair&&>::value,
iterator>
607 {
return _M_h.emplace_hint(__hint, std::forward<_Pair>(__x)); }
619 template<
typename _InputIterator>
621 insert(_InputIterator __first, _InputIterator __last)
622 { _M_h.insert(__first, __last); }
633 { _M_h.insert(__l); }
636#if __cplusplus > 201402L
657 template <
typename _Obj>
661 auto __ret = _M_h.try_emplace(
cend(), __k,
662 std::forward<_Obj>(__obj));
664 __ret.first->second = std::forward<_Obj>(__obj);
669 template <
typename _Obj>
674 std::forward<_Obj>(__obj));
676 __ret.first->second = std::forward<_Obj>(__obj);
706 template <
typename _Obj>
711 auto __ret = _M_h.try_emplace(__hint, __k, std::forward<_Obj>(__obj));
713 __ret.first->second = std::forward<_Obj>(__obj);
718 template <
typename _Obj>
722 auto __ret = _M_h.try_emplace(__hint,
std::move(__k),
723 std::forward<_Obj>(__obj));
725 __ret.first->second = std::forward<_Obj>(__obj);
746 {
return _M_h.erase(__position); }
751 {
return _M_h.erase(__position); }
768 {
return _M_h.erase(__x); }
786 {
return _M_h.erase(__first, __last); }
810 noexcept(
noexcept(_M_h.swap(__x._M_h)) )
811 { _M_h.swap(__x._M_h); }
813#if __cplusplus > 201402L
814 template<
typename,
typename,
typename>
815 friend class std::_Hash_merge_helper;
817 template<
typename _H2,
typename _P2>
821 using _Merge_helper = _Hash_merge_helper<unordered_map, _H2, _P2>;
822 _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source));
825 template<
typename _H2,
typename _P2>
827 merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
830 template<
typename _H2,
typename _P2>
832 merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>& __source)
834 using _Merge_helper = _Hash_merge_helper<unordered_map, _H2, _P2>;
835 _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source));
838 template<
typename _H2,
typename _P2>
840 merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
850 {
return _M_h.hash_function(); }
856 {
return _M_h.key_eq(); }
874 {
return _M_h.find(__x); }
876#if __cplusplus > 201703L
877 template<
typename _Kt>
879 find(
const _Kt& __x) ->
decltype(_M_h._M_find_tr(__x))
880 {
return _M_h._M_find_tr(__x); }
885 {
return _M_h.find(__x); }
887#if __cplusplus > 201703L
888 template<
typename _Kt>
890 find(
const _Kt& __x)
const ->
decltype(_M_h._M_find_tr(__x))
891 {
return _M_h._M_find_tr(__x); }
907 {
return _M_h.count(__x); }
909#if __cplusplus > 201703L
910 template<
typename _Kt>
912 count(
const _Kt& __x)
const ->
decltype(_M_h._M_count_tr(__x))
913 {
return _M_h._M_count_tr(__x); }
917#if __cplusplus > 201703L
926 {
return _M_h.find(__x) != _M_h.end(); }
928 template<
typename _Kt>
931 ->
decltype(_M_h._M_find_tr(__x), void(),
true)
932 {
return _M_h._M_find_tr(__x) != _M_h.end(); }
947 {
return _M_h.equal_range(__x); }
949#if __cplusplus > 201703L
950 template<
typename _Kt>
953 ->
decltype(_M_h._M_equal_range_tr(__x))
954 {
return _M_h._M_equal_range_tr(__x); }
959 {
return _M_h.equal_range(__x); }
961#if __cplusplus > 201703L
962 template<
typename _Kt>
965 ->
decltype(_M_h._M_equal_range_tr(__x))
966 {
return _M_h._M_equal_range_tr(__x); }
985 {
return _M_h[__k]; }
1002 {
return _M_h.at(__k); }
1006 {
return _M_h.at(__k); }
1014 {
return _M_h.bucket_count(); }
1019 {
return _M_h.max_bucket_count(); }
1028 {
return _M_h.bucket_size(__n); }
1036 bucket(
const key_type& __key)
const
1037 {
return _M_h.bucket(__key); }
1047 {
return _M_h.begin(__n); }
1058 {
return _M_h.begin(__n); }
1062 {
return _M_h.cbegin(__n); }
1073 {
return _M_h.end(__n); }
1084 {
return _M_h.end(__n); }
1088 {
return _M_h.cend(__n); }
1096 {
return _M_h.load_factor(); }
1102 {
return _M_h.max_load_factor(); }
1110 { _M_h.max_load_factor(__z); }
1121 { _M_h.rehash(__n); }
1132 { _M_h.reserve(__n); }
1134 template<
typename _Key1,
typename _Tp1,
typename _Hash1,
typename _Pred1,
1141#if __cpp_deduction_guides >= 201606
1143 template<
typename _InputIterator,
1144 typename _Hash = hash<__iter_key_t<_InputIterator>>,
1145 typename _Pred = equal_to<__iter_key_t<_InputIterator>>,
1146 typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>,
1147 typename = _RequireInputIter<_InputIterator>,
1148 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1149 typename = _RequireNotAllocator<_Pred>,
1150 typename = _RequireAllocator<_Allocator>>
1151 unordered_map(_InputIterator, _InputIterator,
1153 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1154 -> unordered_map<__iter_key_t<_InputIterator>,
1155 __iter_val_t<_InputIterator>,
1156 _Hash, _Pred, _Allocator>;
1158 template<
typename _Key,
typename _Tp,
typename _Hash = hash<_Key>,
1159 typename _Pred = equal_to<_Key>,
1160 typename _Allocator = allocator<pair<const _Key, _Tp>>,
1161 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1162 typename = _RequireNotAllocator<_Pred>,
1163 typename = _RequireAllocator<_Allocator>>
1164 unordered_map(initializer_list<pair<_Key, _Tp>>,
1166 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1167 -> unordered_map<_Key, _Tp, _Hash, _Pred, _Allocator>;
1169 template<
typename _InputIterator,
typename _Allocator,
1170 typename = _RequireInputIter<_InputIterator>,
1171 typename = _RequireAllocator<_Allocator>>
1172 unordered_map(_InputIterator, _InputIterator,
1174 -> unordered_map<__iter_key_t<_InputIterator>,
1175 __iter_val_t<_InputIterator>,
1176 hash<__iter_key_t<_InputIterator>>,
1177 equal_to<__iter_key_t<_InputIterator>>,
1180 template<
typename _InputIterator,
typename _Allocator,
1181 typename = _RequireInputIter<_InputIterator>,
1182 typename = _RequireAllocator<_Allocator>>
1183 unordered_map(_InputIterator, _InputIterator, _Allocator)
1184 -> unordered_map<__iter_key_t<_InputIterator>,
1185 __iter_val_t<_InputIterator>,
1186 hash<__iter_key_t<_InputIterator>>,
1187 equal_to<__iter_key_t<_InputIterator>>,
1190 template<
typename _InputIterator,
typename _Hash,
typename _Allocator,
1191 typename = _RequireInputIter<_InputIterator>,
1192 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1193 typename = _RequireAllocator<_Allocator>>
1194 unordered_map(_InputIterator, _InputIterator,
1197 -> unordered_map<__iter_key_t<_InputIterator>,
1198 __iter_val_t<_InputIterator>, _Hash,
1199 equal_to<__iter_key_t<_InputIterator>>, _Allocator>;
1201 template<
typename _Key,
typename _Tp,
typename _Allocator,
1202 typename = _RequireAllocator<_Allocator>>
1203 unordered_map(initializer_list<pair<_Key, _Tp>>,
1206 -> unordered_map<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>;
1208 template<
typename _Key,
typename _Tp,
typename _Allocator,
1209 typename = _RequireAllocator<_Allocator>>
1210 unordered_map(initializer_list<pair<_Key, _Tp>>, _Allocator)
1211 -> unordered_map<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>;
1213 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Allocator,
1214 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1215 typename = _RequireAllocator<_Allocator>>
1216 unordered_map(initializer_list<pair<_Key, _Tp>>,
1219 -> unordered_map<_Key, _Tp, _Hash, equal_to<_Key>, _Allocator>;
1246 template<
typename _Key,
typename _Tp,
1247 typename _Hash = hash<_Key>,
1248 typename _Pred = equal_to<_Key>,
1249 typename _Alloc = allocator<std::pair<const _Key, _Tp>>>
1252 typedef __ummap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Hashtable;
1281#if __cplusplus > 201402L
1282 using node_type =
typename _Hashtable::node_type;
1302 : _M_h(__n, __hf, __eql, __a)
1318 template<
typename _InputIterator>
1324 : _M_h(__first, __last, __n, __hf, __eql, __a)
1349 : _M_h(__ummap._M_h, __a)
1359 noexcept(
noexcept(_Hashtable(
std::move(__ummap._M_h), __a)) )
1379 : _M_h(__l, __n, __hf, __eql, __a)
1391 template<
typename _InputIterator>
1398 template<
typename _InputIterator>
1446 {
return _M_h.get_allocator(); }
1451 _GLIBCXX_NODISCARD
bool
1453 {
return _M_h.empty(); }
1458 {
return _M_h.size(); }
1463 {
return _M_h.max_size(); }
1473 {
return _M_h.begin(); }
1482 {
return _M_h.begin(); }
1486 {
return _M_h.begin(); }
1495 {
return _M_h.end(); }
1504 {
return _M_h.end(); }
1508 {
return _M_h.end(); }
1528 template<
typename... _Args>
1531 {
return _M_h.emplace(std::forward<_Args>(__args)...); }
1555 template<
typename... _Args>
1558 {
return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
1572 {
return _M_h.insert(__x); }
1578 template<
typename _Pair>
1579 __enable_if_t<is_constructible<value_type, _Pair&&>::value,
iterator>
1581 {
return _M_h.emplace(std::forward<_Pair>(__x)); }
1606 {
return _M_h.insert(__hint, __x); }
1612 {
return _M_h.insert(__hint,
std::move(__x)); }
1614 template<
typename _Pair>
1615 __enable_if_t<is_constructible<value_type, _Pair&&>::value,
iterator>
1617 {
return _M_h.emplace_hint(__hint, std::forward<_Pair>(__x)); }
1629 template<
typename _InputIterator>
1631 insert(_InputIterator __first, _InputIterator __last)
1632 { _M_h.insert(__first, __last); }
1644 { _M_h.insert(__l); }
1646#if __cplusplus > 201402L
1651 __glibcxx_assert(__pos !=
end());
1652 return _M_h.extract(__pos);
1658 {
return _M_h.extract(__key); }
1663 {
return _M_h._M_reinsert_node_multi(
cend(),
std::move(__nh)); }
1668 {
return _M_h._M_reinsert_node_multi(__hint,
std::move(__nh)); }
1687 {
return _M_h.erase(__position); }
1692 {
return _M_h.erase(__position); }
1708 {
return _M_h.erase(__x); }
1727 {
return _M_h.erase(__first, __last); }
1751 noexcept(
noexcept(_M_h.swap(__x._M_h)) )
1752 { _M_h.swap(__x._M_h); }
1754#if __cplusplus > 201402L
1755 template<
typename,
typename,
typename>
1756 friend class std::_Hash_merge_helper;
1758 template<
typename _H2,
typename _P2>
1763 = _Hash_merge_helper<unordered_multimap, _H2, _P2>;
1764 _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source));
1767 template<
typename _H2,
typename _P2>
1769 merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
1770 { merge(__source); }
1772 template<
typename _H2,
typename _P2>
1774 merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>& __source)
1777 = _Hash_merge_helper<unordered_multimap, _H2, _P2>;
1778 _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source));
1781 template<
typename _H2,
typename _P2>
1783 merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
1784 { merge(__source); }
1793 {
return _M_h.hash_function(); }
1799 {
return _M_h.key_eq(); }
1817 {
return _M_h.find(__x); }
1819#if __cplusplus > 201703L
1820 template<
typename _Kt>
1822 find(
const _Kt& __x) ->
decltype(_M_h._M_find_tr(__x))
1823 {
return _M_h._M_find_tr(__x); }
1828 {
return _M_h.find(__x); }
1830#if __cplusplus > 201703L
1831 template<
typename _Kt>
1833 find(
const _Kt& __x)
const ->
decltype(_M_h._M_find_tr(__x))
1834 {
return _M_h._M_find_tr(__x); }
1846 {
return _M_h.count(__x); }
1848#if __cplusplus > 201703L
1849 template<
typename _Kt>
1851 count(
const _Kt& __x)
const ->
decltype(_M_h._M_count_tr(__x))
1852 {
return _M_h._M_count_tr(__x); }
1856#if __cplusplus > 201703L
1865 {
return _M_h.find(__x) != _M_h.end(); }
1867 template<
typename _Kt>
1870 ->
decltype(_M_h._M_find_tr(__x), void(),
true)
1871 {
return _M_h._M_find_tr(__x) != _M_h.end(); }
1884 {
return _M_h.equal_range(__x); }
1886#if __cplusplus > 201703L
1887 template<
typename _Kt>
1890 ->
decltype(_M_h._M_equal_range_tr(__x))
1891 {
return _M_h._M_equal_range_tr(__x); }
1896 {
return _M_h.equal_range(__x); }
1898#if __cplusplus > 201703L
1899 template<
typename _Kt>
1902 ->
decltype(_M_h._M_equal_range_tr(__x))
1903 {
return _M_h._M_equal_range_tr(__x); }
1912 {
return _M_h.bucket_count(); }
1917 {
return _M_h.max_bucket_count(); }
1926 {
return _M_h.bucket_size(__n); }
1934 bucket(
const key_type& __key)
const
1935 {
return _M_h.bucket(__key); }
1945 {
return _M_h.begin(__n); }
1956 {
return _M_h.begin(__n); }
1960 {
return _M_h.cbegin(__n); }
1971 {
return _M_h.end(__n); }
1982 {
return _M_h.end(__n); }
1986 {
return _M_h.cend(__n); }
1994 {
return _M_h.load_factor(); }
2000 {
return _M_h.max_load_factor(); }
2008 { _M_h.max_load_factor(__z); }
2019 { _M_h.rehash(__n); }
2030 { _M_h.reserve(__n); }
2032 template<
typename _Key1,
typename _Tp1,
typename _Hash1,
typename _Pred1,
2036 _Hash1, _Pred1, _Alloc1>&,
2038 _Hash1, _Pred1, _Alloc1>&);
2041#if __cpp_deduction_guides >= 201606
2043 template<
typename _InputIterator,
2044 typename _Hash = hash<__iter_key_t<_InputIterator>>,
2045 typename _Pred = equal_to<__iter_key_t<_InputIterator>>,
2046 typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>,
2047 typename = _RequireInputIter<_InputIterator>,
2048 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2049 typename = _RequireNotAllocator<_Pred>,
2050 typename = _RequireAllocator<_Allocator>>
2051 unordered_multimap(_InputIterator, _InputIterator,
2053 _Hash = _Hash(), _Pred = _Pred(),
2054 _Allocator = _Allocator())
2055 -> unordered_multimap<__iter_key_t<_InputIterator>,
2056 __iter_val_t<_InputIterator>, _Hash, _Pred,
2059 template<
typename _Key,
typename _Tp,
typename _Hash = hash<_Key>,
2060 typename _Pred = equal_to<_Key>,
2061 typename _Allocator = allocator<pair<const _Key, _Tp>>,
2062 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2063 typename = _RequireNotAllocator<_Pred>,
2064 typename = _RequireAllocator<_Allocator>>
2065 unordered_multimap(initializer_list<pair<_Key, _Tp>>,
2067 _Hash = _Hash(), _Pred = _Pred(),
2068 _Allocator = _Allocator())
2069 -> unordered_multimap<_Key, _Tp, _Hash, _Pred, _Allocator>;
2071 template<
typename _InputIterator,
typename _Allocator,
2072 typename = _RequireInputIter<_InputIterator>,
2073 typename = _RequireAllocator<_Allocator>>
2074 unordered_multimap(_InputIterator, _InputIterator,
2076 -> unordered_multimap<__iter_key_t<_InputIterator>,
2077 __iter_val_t<_InputIterator>,
2078 hash<__iter_key_t<_InputIterator>>,
2079 equal_to<__iter_key_t<_InputIterator>>, _Allocator>;
2081 template<
typename _InputIterator,
typename _Allocator,
2082 typename = _RequireInputIter<_InputIterator>,
2083 typename = _RequireAllocator<_Allocator>>
2084 unordered_multimap(_InputIterator, _InputIterator, _Allocator)
2085 -> unordered_multimap<__iter_key_t<_InputIterator>,
2086 __iter_val_t<_InputIterator>,
2087 hash<__iter_key_t<_InputIterator>>,
2088 equal_to<__iter_key_t<_InputIterator>>, _Allocator>;
2090 template<
typename _InputIterator,
typename _Hash,
typename _Allocator,
2091 typename = _RequireInputIter<_InputIterator>,
2092 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2093 typename = _RequireAllocator<_Allocator>>
2094 unordered_multimap(_InputIterator, _InputIterator,
2097 -> unordered_multimap<__iter_key_t<_InputIterator>,
2098 __iter_val_t<_InputIterator>, _Hash,
2099 equal_to<__iter_key_t<_InputIterator>>, _Allocator>;
2101 template<
typename _Key,
typename _Tp,
typename _Allocator,
2102 typename = _RequireAllocator<_Allocator>>
2103 unordered_multimap(initializer_list<pair<_Key, _Tp>>,
2106 -> unordered_multimap<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>;
2108 template<
typename _Key,
typename _Tp,
typename _Allocator,
2109 typename = _RequireAllocator<_Allocator>>
2110 unordered_multimap(initializer_list<pair<_Key, _Tp>>, _Allocator)
2111 -> unordered_multimap<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>;
2113 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Allocator,
2114 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2115 typename = _RequireAllocator<_Allocator>>
2116 unordered_multimap(initializer_list<pair<_Key, _Tp>>,
2119 -> unordered_multimap<_Key, _Tp, _Hash, equal_to<_Key>, _Allocator>;
2123 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2125 swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2126 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2127 noexcept(
noexcept(__x.swap(__y)))
2130 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2132 swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2133 unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2134 noexcept(
noexcept(__x.swap(__y)))
2137 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2139 operator==(
const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2140 const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2141 {
return __x._M_h._M_equal(__y._M_h); }
2143#if __cpp_impl_three_way_comparison < 201907L
2144 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2146 operator!=(
const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2147 const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2148 {
return !(__x == __y); }
2151 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2153 operator==(
const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2154 const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2155 {
return __x._M_h._M_equal(__y._M_h); }
2157#if __cpp_impl_three_way_comparison < 201907L
2158 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2160 operator!=(
const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2161 const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2162 {
return !(__x == __y); }
2165_GLIBCXX_END_NAMESPACE_CONTAINER
2167#if __cplusplus > 201402L
2169 template<
typename _Key,
typename _Val,
typename _Hash1,
typename _Eq1,
2170 typename _Alloc,
typename _Hash2,
typename _Eq2>
2171 struct _Hash_merge_helper<
2172 _GLIBCXX_STD_C::unordered_map<_Key, _Val, _Hash1, _Eq1, _Alloc>,
2176 template<
typename... _Tp>
2177 using unordered_map = _GLIBCXX_STD_C::unordered_map<_Tp...>;
2178 template<
typename... _Tp>
2179 using unordered_multimap = _GLIBCXX_STD_C::unordered_multimap<_Tp...>;
2181 friend unordered_map<_Key, _Val, _Hash1, _Eq1, _Alloc>;
2184 _S_get_table(unordered_map<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
2185 {
return __map._M_h; }
2188 _S_get_table(unordered_multimap<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
2189 {
return __map._M_h; }
2193 template<
typename _Key,
typename _Val,
typename _Hash1,
typename _Eq1,
2194 typename _Alloc,
typename _Hash2,
typename _Eq2>
2195 struct _Hash_merge_helper<
2196 _GLIBCXX_STD_C::unordered_multimap<_Key, _Val, _Hash1, _Eq1, _Alloc>,
2200 template<
typename... _Tp>
2201 using unordered_map = _GLIBCXX_STD_C::unordered_map<_Tp...>;
2202 template<
typename... _Tp>
2203 using unordered_multimap = _GLIBCXX_STD_C::unordered_multimap<_Tp...>;
2205 friend unordered_multimap<_Key, _Val, _Hash1, _Eq1, _Alloc>;
2208 _S_get_table(unordered_map<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
2209 {
return __map._M_h; }
2212 _S_get_table(unordered_multimap<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
2213 {
return __map._M_h; }
2217_GLIBCXX_END_NAMESPACE_VERSION
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
ISO C++ entities toplevel namespace is std.
__detail::_Hashtable_traits< _Cache, false, false > __ummap_traits
Base types for unordered_multimap.
__detail::_Hashtable_traits< _Cache, false, true > __umap_traits
Base types for unordered_map.
Primary class template hash.
The standard allocator, as per C++03 [20.4.1].
One of the comparison functors.
Struct holding two objects of arbitrary type.
A standard container composed of equivalent keys (possibly containing multiple of each key value) tha...
float load_factor() const noexcept
Returns the average number of elements per bucket.
_Hashtable::reference reference
Iterator-related typedefs.
iterator erase(iterator __position)
Erases an element from an unordered_multimap.
const_iterator end() const noexcept
size_type erase(const key_type &__x)
Erases elements according to the provided key.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
size_type bucket_count() const noexcept
Returns the number of buckets of the unordered_multimap.
_Hashtable::iterator iterator
Iterator-related typedefs.
size_type max_bucket_count() const noexcept
Returns the maximum number of buckets of the unordered_multimap.
iterator begin() noexcept
const_iterator begin() const noexcept
hasher hash_function() const
Returns the hash functor object with which the unordered_multimap was constructed.
iterator insert(const_iterator __hint, node_type &&__nh)
Re-insert an extracted node.
__enable_if_t< is_constructible< value_type, _Pair && >::value, iterator > insert(const_iterator __hint, _Pair &&__x)
Inserts a std::pair into the unordered_multimap.
unordered_multimap & operator=(const unordered_multimap &)=default
Copy assignment operator.
key_equal key_eq() const
Returns the key comparison object with which the unordered_multimap was constructed.
size_type count(const key_type &__x) const
Finds the number of elements.
const_iterator find(const key_type &__x) const
Tries to locate an element in an unordered_multimap.
_Hashtable::mapped_type mapped_type
Public typedefs.
auto find(const _Kt &__x) -> decltype(_M_h._M_find_tr(__x))
Tries to locate an element in an unordered_multimap.
local_iterator end(size_type __n)
Returns a read/write iterator pointing to one past the last bucket elements.
void insert(_InputIterator __first, _InputIterator __last)
A template function that attempts to insert a range of elements.
unordered_multimap & operator=(initializer_list< value_type > __l)
Unordered_multimap list assignment operator.
unordered_multimap(size_type __n, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type())
Default constructor creates no elements.
_Hashtable::value_type value_type
Public typedefs.
iterator emplace(_Args &&... __args)
Attempts to build and insert a std::pair into the unordered_multimap.
node_type extract(const key_type &__key)
Extract a node.
bool contains(const key_type &__x) const
Finds whether an element with the given key exists.
_Hashtable::const_reference const_reference
Iterator-related typedefs.
iterator insert(node_type &&__nh)
Re-insert an extracted node.
iterator erase(const_iterator __position)
Erases an element from an unordered_multimap.
local_iterator begin(size_type __n)
Returns a read/write iterator pointing to the first bucket element.
float max_load_factor() const noexcept
Returns a positive number that the unordered_multimap tries to keep the load factor less than or equa...
unordered_multimap()=default
Default constructor.
iterator insert(value_type &&__x)
Inserts a std::pair into the unordered_multimap.
iterator insert(const value_type &__x)
Inserts a std::pair into the unordered_multimap.
unordered_multimap & operator=(unordered_multimap &&)=default
Move assignment operator.
_Hashtable::hasher hasher
Public typedefs.
_Hashtable::local_iterator local_iterator
Iterator-related typedefs.
void reserve(size_type __n)
Prepare the unordered_multimap for a specified number of elements.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n=0, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type())
Builds an unordered_multimap from a range.
iterator find(const key_type &__x)
Tries to locate an element in an unordered_multimap.
unordered_multimap(initializer_list< value_type > __l, size_type __n=0, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type())
Builds an unordered_multimap from an initializer_list.
auto count(const _Kt &__x) const -> decltype(_M_h._M_count_tr(__x))
Finds the number of elements.
iterator erase(const_iterator __first, const_iterator __last)
Erases a [__first,__last) range of elements from an unordered_multimap.
const_local_iterator end(size_type __n) const
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
_Hashtable::pointer pointer
Iterator-related typedefs.
_Hashtable::allocator_type allocator_type
Public typedefs.
const_local_iterator begin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
auto find(const _Kt &__x) const -> decltype(_M_h._M_find_tr(__x))
Tries to locate an element in an unordered_multimap.
_Hashtable::const_local_iterator const_local_iterator
Iterator-related typedefs.
unordered_multimap(unordered_multimap &&)=default
Move constructor.
unordered_multimap(const allocator_type &__a)
Creates an unordered_multimap with no elements.
_Hashtable::difference_type difference_type
Iterator-related typedefs.
_Hashtable::size_type size_type
Iterator-related typedefs.
_Hashtable::const_pointer const_pointer
Iterator-related typedefs.
__enable_if_t< is_constructible< value_type, _Pair && >::value, iterator > insert(_Pair &&__x)
Inserts a std::pair into the unordered_multimap.
auto contains(const _Kt &__x) const -> decltype(_M_h._M_find_tr(__x), void(), true)
Finds whether an element with the given key exists.
void swap(unordered_multimap &__x) noexcept(noexcept(_M_h.swap(__x._M_h)))
Swaps data with another unordered_multimap.
void rehash(size_type __n)
May rehash the unordered_multimap.
_Hashtable::const_iterator const_iterator
Iterator-related typedefs.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the unordered_multimap.
const_iterator cend() const noexcept
size_type max_size() const noexcept
Returns the maximum size of the unordered_multimap.
const_local_iterator cbegin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
bool empty() const noexcept
Returns true if the unordered_multimap is empty.
const_iterator cbegin() const noexcept
_Hashtable::key_type key_type
Public typedefs.
node_type extract(const_iterator __pos)
Extract a node.
const_local_iterator cend(size_type __n) const
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
iterator insert(const_iterator __hint, const value_type &__x)
Inserts a std::pair into the unordered_multimap.
size_type size() const noexcept
Returns the size of the unordered_multimap.
unordered_multimap(const unordered_multimap &)=default
Copy constructor.
iterator emplace_hint(const_iterator __pos, _Args &&... __args)
Attempts to build and insert a std::pair into the unordered_multimap.
iterator insert(const_iterator __hint, value_type &&__x)
Inserts a std::pair into the unordered_multimap.
auto equal_range(const _Kt &__x) -> decltype(_M_h._M_equal_range_tr(__x))
Finds a subsequence matching given key.
_Hashtable::key_equal key_equal
Public typedefs.
allocator_type get_allocator() const noexcept
Returns the allocator object used by the unordered_multimap.
void max_load_factor(float __z)
Change the unordered_multimap maximum load factor.
auto equal_range(const _Kt &__x) const -> decltype(_M_h._M_equal_range_tr(__x))
Finds a subsequence matching given key.
A standard container composed of unique keys (containing at most one of each key value) that associat...
iterator insert(const_iterator __hint, value_type &&__x)
Attempts to insert a std::pair into the unordered_map.
_Hashtable::iterator iterator
Iterator-related typedefs.
void max_load_factor(float __z)
Change the unordered_map maximum load factor.
const mapped_type & at(const key_type &__k) const
Access to unordered_map data.
bool contains(const key_type &__x) const
Finds whether an element with the given key exists.
node_type extract(const key_type &__key)
Extract a node.
void insert(_InputIterator __first, _InputIterator __last)
A template function that attempts to insert a range of elements.
allocator_type get_allocator() const noexcept
Returns the allocator object used by the unordered_map.
auto find(const _Kt &__x) -> decltype(_M_h._M_find_tr(__x))
Tries to locate an element in an unordered_map.
unordered_map & operator=(initializer_list< value_type > __l)
Unordered_map list assignment operator.
_Hashtable::const_pointer const_pointer
Iterator-related typedefs.
auto find(const _Kt &__x) const -> decltype(_M_h._M_find_tr(__x))
Tries to locate an element in an unordered_map.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the unordered_map.
__enable_if_t< is_constructible< value_type, _Pair && >::value, iterator > insert(const_iterator __hint, _Pair &&__x)
Attempts to insert a std::pair into the unordered_map.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
mapped_type & at(const key_type &__k)
Access to unordered_map data.
iterator erase(const_iterator __first, const_iterator __last)
Erases a [__first,__last) range of elements from an unordered_map.
iterator try_emplace(const_iterator __hint, const key_type &__k, _Args &&... __args)
Attempts to build and insert a std::pair into the unordered_map.
node_type extract(const_iterator __pos)
Extract a node.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert a std::pair into the unordered_map.
void reserve(size_type __n)
Prepare the unordered_map for a specified number of elements.
const_local_iterator cbegin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
iterator insert(const_iterator, node_type &&__nh)
Re-insert an extracted node.
_Hashtable::reference reference
Iterator-related typedefs.
iterator insert(const_iterator __hint, const value_type &__x)
Attempts to insert a std::pair into the unordered_map.
_Hashtable::allocator_type allocator_type
Public typedefs.
unordered_map(const unordered_map &)=default
Copy constructor.
size_type count(const key_type &__x) const
Finds the number of elements.
bool empty() const noexcept
Returns true if the unordered_map is empty.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
const_iterator find(const key_type &__x) const
Tries to locate an element in an unordered_map.
unordered_map(unordered_map &&)=default
Move constructor.
const_local_iterator end(size_type __n) const
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
auto equal_range(const _Kt &__x) -> decltype(_M_h._M_equal_range_tr(__x))
Finds a subsequence matching given key.
auto contains(const _Kt &__x) const -> decltype(_M_h._M_find_tr(__x), void(), true)
Finds whether an element with the given key exists.
size_type max_size() const noexcept
Returns the maximum size of the unordered_map.
const_iterator end() const noexcept
unordered_map()=default
Default constructor.
_Hashtable::mapped_type mapped_type
Public typedefs.
unordered_map & operator=(unordered_map &&)=default
Move assignment operator.
const_local_iterator begin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
unordered_map(size_type __n, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type())
Default constructor creates no elements.
std::pair< iterator, bool > emplace(_Args &&... __args)
Attempts to build and insert a std::pair into the unordered_map.
const_local_iterator cend(size_type __n) const
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
size_type size() const noexcept
Returns the size of the unordered_map.
__enable_if_t< is_constructible< value_type, _Pair && >::value, pair< iterator, bool > > insert(_Pair &&__x)
Attempts to insert a std::pair into the unordered_map.
mapped_type & operator[](key_type &&__k)
Subscript ( [] ) access to unordered_map data.
std::pair< iterator, bool > insert(value_type &&__x)
Attempts to insert a std::pair into the unordered_map.
_Hashtable::hasher hasher
Public typedefs.
pair< iterator, bool > insert_or_assign(const key_type &__k, _Obj &&__obj)
Attempts to insert a std::pair into the unordered_map.
unordered_map(_InputIterator __first, _InputIterator __last, size_type __n=0, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type())
Builds an unordered_map from a range.
mapped_type & operator[](const key_type &__k)
Subscript ( [] ) access to unordered_map data.
pair< iterator, bool > try_emplace(const key_type &__k, _Args &&... __args)
Attempts to build and insert a std::pair into the unordered_map.
const_iterator begin() const noexcept
key_equal key_eq() const
Returns the key comparison object with which the unordered_map was constructed.
_Hashtable::const_reference const_reference
Iterator-related typedefs.
_Hashtable::key_equal key_equal
Public typedefs.
_Hashtable::local_iterator local_iterator
Iterator-related typedefs.
iterator erase(iterator __position)
Erases an element from an unordered_map.
const_iterator cend() const noexcept
local_iterator end(size_type __n)
Returns a read/write iterator pointing to one past the last bucket elements.
_Hashtable::pointer pointer
Iterator-related typedefs.
iterator insert_or_assign(const_iterator __hint, const key_type &__k, _Obj &&__obj)
Attempts to insert a std::pair into the unordered_map.
unordered_map(const allocator_type &__a)
Creates an unordered_map with no elements.
_Hashtable::key_type key_type
Public typedefs.
size_type bucket_count() const noexcept
Returns the number of buckets of the unordered_map.
iterator begin() noexcept
hasher hash_function() const
Returns the hash functor object with which the unordered_map was constructed.
auto equal_range(const _Kt &__x) const -> decltype(_M_h._M_equal_range_tr(__x))
Finds a subsequence matching given key.
unordered_map(initializer_list< value_type > __l, size_type __n=0, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type())
Builds an unordered_map from an initializer_list.
_Hashtable::const_iterator const_iterator
Iterator-related typedefs.
_Hashtable::size_type size_type
Iterator-related typedefs.
iterator find(const key_type &__x)
Tries to locate an element in an unordered_map.
float load_factor() const noexcept
Returns the average number of elements per bucket.
iterator erase(const_iterator __position)
Erases an element from an unordered_map.
void swap(unordered_map &__x) noexcept(noexcept(_M_h.swap(__x._M_h)))
Swaps data with another unordered_map.
local_iterator begin(size_type __n)
Returns a read/write iterator pointing to the first bucket element.
float max_load_factor() const noexcept
Returns a positive number that the unordered_map tries to keep the load factor less than or equal to.
unordered_map & operator=(const unordered_map &)=default
Copy assignment operator.
_Hashtable::difference_type difference_type
Iterator-related typedefs.
auto count(const _Kt &__x) const -> decltype(_M_h._M_count_tr(__x))
Finds the number of elements.
_Hashtable::const_local_iterator const_local_iterator
Iterator-related typedefs.
size_type max_bucket_count() const noexcept
Returns the maximum number of buckets of the unordered_map.
iterator emplace_hint(const_iterator __pos, _Args &&... __args)
Attempts to build and insert a std::pair into the unordered_map.
insert_return_type insert(node_type &&__nh)
Re-insert an extracted node.
_Hashtable::value_type value_type
Public typedefs.
void rehash(size_type __n)
May rehash the unordered_map.
const_iterator cbegin() const noexcept