30#ifndef _UNORDERED_MAP_H
31#define _UNORDERED_MAP_H
37#if __glibcxx_containers_ranges
41namespace std _GLIBCXX_VISIBILITY(default)
43_GLIBCXX_BEGIN_NAMESPACE_VERSION
44_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
50 template<
typename _Key,
56 using __umap_hashtable = _Hashtable<_Key, std::pair<const _Key, _Tp>,
57 _Alloc, __detail::_Select1st,
59 __detail::_Mod_range_hashing,
60 __detail::_Default_ranged_hash,
61 __detail::_Prime_rehash_policy, _Tr>;
67 template<
typename _Key,
73 using __ummap_hashtable = _Hashtable<_Key, std::pair<const _Key, _Tp>,
74 _Alloc, __detail::_Select1st,
76 __detail::_Mod_range_hashing,
77 __detail::_Default_ranged_hash,
78 __detail::_Prime_rehash_policy, _Tr>;
80 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
108 template<
typename _Key,
typename _Tp,
114 typedef __umap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Hashtable;
124 typedef typename _Hashtable::hasher
hasher;
143#ifdef __glibcxx_node_extract
144 using node_type =
typename _Hashtable::node_type;
145 using insert_return_type =
typename _Hashtable::insert_return_type;
165 : _M_h(__n, __hf, __eql, __a)
181 template<
typename _InputIterator>
187 : _M_h(__first, __last, __n, __hf, __eql, __a)
211 const allocator_type& __a)
212 : _M_h(__umap._M_h, __a)
221 const allocator_type& __a)
222 noexcept(
noexcept(_Hashtable(
std::move(__umap._M_h), __a)) )
223 : _M_h(
std::
move(__umap._M_h), __a)
242 : _M_h(__l, __n, __hf, __eql, __a)
250 const allocator_type& __a)
251 : unordered_map(__n, __hf,
key_equal(), __a)
256 template<
typename _InputIterator>
262 template<
typename _InputIterator>
269 template<
typename _InputIterator>
295#if __glibcxx_containers_ranges
309 template<__detail::__container_compatible_range<value_type> _Rg>
315 : _M_h(__n, __hf, __eql, __a)
320 template<__detail::__container_compatible_range<value_type> _Rg>
325 template<__detail::__container_compatible_range<value_type> _Rg>
331 template<__detail::__container_compatible_range<value_type> _Rg>
367 {
return _M_h.get_allocator(); }
372 _GLIBCXX_NODISCARD
bool
374 {
return _M_h.empty(); }
379 {
return _M_h.size(); }
384 {
return _M_h.max_size(); }
394 {
return _M_h.begin(); }
403 {
return _M_h.begin(); }
407 {
return _M_h.begin(); }
416 {
return _M_h.end(); }
425 {
return _M_h.end(); }
429 {
return _M_h.end(); }
454 template<
typename... _Args>
486 template<
typename... _Args>
491#ifdef __glibcxx_node_extract
494 extract(const_iterator __pos)
496 __glibcxx_assert(__pos !=
end());
497 return _M_h.extract(__pos);
503 {
return _M_h.extract(__key); }
505#ifdef __glibcxx_associative_heterogeneous_erasure
506 template <__heterogeneous_hash_key<unordered_map> _Kt>
509 {
return _M_h._M_extract_tr(__key); }
515 {
return _M_h._M_reinsert_node(
std::move(__nh)); }
520 {
return _M_h._M_reinsert_node(
std::move(__nh)).position; }
523#ifdef __glibcxx_unordered_map_try_emplace
547 template <
typename... _Args>
549 try_emplace(
const key_type& __k, _Args&&... __args)
555 template <
typename... _Args>
557 try_emplace(
key_type&& __k, _Args&&... __args)
563#ifdef __glibcxx_associative_heterogeneous_insertion
564 template <__heterogeneous_hash_key<unordered_map> _Kt,
typename ..._Args>
566 try_emplace(_Kt&& __k, _Args&&... __args)
568 return _M_h.try_emplace(
cend(),
603 template <
typename... _Args>
608 return _M_h.try_emplace(__hint, __k,
613 template <
typename... _Args>
617 return _M_h.try_emplace(__hint,
std::move(__k),
622#ifdef __glibcxx_associative_heterogeneous_insertion
623 template <__heterogeneous_hash_key<unordered_map> _Kt,
typename ..._Args>
627 return _M_h.try_emplace(__hint,
653 {
return _M_h.insert(__x); }
661 template<
typename _Pair>
662 __enable_if_t<is_constructible<value_type, _Pair&&>::value,
692 {
return _M_h.insert(__hint, __x); }
698 {
return _M_h.insert(__hint,
std::move(__x)); }
700 template<
typename _Pair>
701 __enable_if_t<is_constructible<value_type, _Pair&&>::value,
iterator>
715 template<
typename _InputIterator>
717 insert(_InputIterator __first, _InputIterator __last)
718 { _M_h.insert(__first, __last); }
729 { _M_h.insert(__l); }
731#if __glibcxx_containers_ranges
738 template<__detail::__container_compatible_range<value_type> _Rg>
740 insert_range(_Rg&& __rg)
742 auto __first = ranges::begin(__rg);
743 const auto __last = ranges::end(__rg);
744 for (; __first != __last; ++__first)
745 _M_h.emplace(*__first);
749#ifdef __glibcxx_unordered_map_try_emplace
771 template <
typename _Obj>
773 insert_or_assign(
const key_type& __k, _Obj&& __obj)
775 auto __ret = _M_h.try_emplace(
cend(), __k,
783 template <
typename _Obj>
785 insert_or_assign(
key_type&& __k, _Obj&& __obj)
794#ifdef __glibcxx_associative_heterogeneous_insertion
795 template <__heterogeneous_hash_key<unordered_map> _Kt,
typename _Obj>
797 insert_or_assign(_Kt&& __k, _Obj&& __obj)
799 auto __ret = _M_h.try_emplace(
835 template <
typename _Obj>
847 template <
typename _Obj>
851 auto __ret = _M_h.try_emplace(__hint,
std::move(__k),
858#ifdef __glibcxx_associative_heterogeneous_insertion
859 template <__heterogeneous_hash_key<unordered_map> _Kt,
typename _Obj>
863 auto __ret = _M_h.try_emplace(__hint,
889 {
return _M_h.erase(__position); }
894 {
return _M_h.erase(__position); }
912 {
return _M_h.erase(__x); }
914#ifdef __glibcxx_associative_heterogeneous_erasure
915 template <__heterogeneous_hash_key<unordered_map> _Kt>
918 {
return _M_h._M_erase_tr(__key); }
938 {
return _M_h.erase(__first, __last); }
962 noexcept(
noexcept(_M_h.swap(__x._M_h)) )
963 { _M_h.swap(__x._M_h); }
965#ifdef __glibcxx_node_extract
966 template<
typename,
typename,
typename>
967 friend class std::_Hash_merge_helper;
969 template<
typename _H2,
typename _P2>
973 if constexpr (is_same_v<_H2, _Hash> && is_same_v<_P2, _Pred>)
977 using _Merge_helper = _Hash_merge_helper<unordered_map, _H2, _P2>;
978 _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source));
981 template<
typename _H2,
typename _P2>
983 merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
985 using _Merge_helper = _Hash_merge_helper<unordered_map, _H2, _P2>;
986 _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source));
989 template<
typename _H2,
typename _P2>
991 merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>& __source)
993 using _Merge_helper = _Hash_merge_helper<unordered_map, _H2, _P2>;
994 _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source));
997 template<
typename _H2,
typename _P2>
999 merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
1000 { merge(__source); }
1009 {
return _M_h.hash_function(); }
1015 {
return _M_h.key_eq(); }
1033 {
return _M_h.find(__x); }
1035#ifdef __glibcxx_generic_unordered_lookup
1036 template<
typename _Kt>
1038 find(
const _Kt& __x) ->
decltype(_M_h._M_find_tr(__x))
1039 {
return _M_h._M_find_tr(__x); }
1044 {
return _M_h.find(__x); }
1046#ifdef __glibcxx_generic_unordered_lookup
1047 template<
typename _Kt>
1049 find(
const _Kt& __x)
const ->
decltype(_M_h._M_find_tr(__x))
1050 {
return _M_h._M_find_tr(__x); }
1066 {
return _M_h.count(__x); }
1068#ifdef __glibcxx_generic_unordered_lookup
1069 template<
typename _Kt>
1071 count(
const _Kt& __x)
const ->
decltype(_M_h._M_count_tr(__x))
1072 {
return _M_h._M_count_tr(__x); }
1076#if __cplusplus > 201703L
1085 {
return _M_h.find(__x) != _M_h.end(); }
1087 template<
typename _Kt>
1090 ->
decltype(_M_h._M_find_tr(__x),
void(),
true)
1091 {
return _M_h._M_find_tr(__x) != _M_h.end(); }
1106 {
return _M_h.equal_range(__x); }
1108#ifdef __glibcxx_generic_unordered_lookup
1109 template<
typename _Kt>
1112 ->
decltype(_M_h._M_equal_range_tr(__x))
1113 {
return _M_h._M_equal_range_tr(__x); }
1118 {
return _M_h.equal_range(__x); }
1120#ifdef __glibcxx_generic_unordered_lookup
1121 template<
typename _Kt>
1124 ->
decltype(_M_h._M_equal_range_tr(__x))
1125 {
return _M_h._M_equal_range_tr(__x); }
1144 {
return _M_h[__k]; }
1150#ifdef __glibcxx_associative_heterogeneous_insertion
1151 template <__heterogeneous_hash_key<unordered_map> _Kt>
1170 {
return _M_h.at(__k); }
1172#ifdef __glibcxx_associative_heterogeneous_insertion
1173 template <__heterogeneous_hash_key<unordered_map> _Kt>
1176 {
return _M_h._M_at_tr(__k); }
1181 {
return _M_h.at(__k); }
1183#ifdef __glibcxx_associative_heterogeneous_insertion
1184 template <__heterogeneous_hash_key<unordered_map> _Kt>
1186 at(
const _Kt& __k)
const
1187 {
return _M_h._M_at_tr(__k); }
1196 {
return _M_h.bucket_count(); }
1201 {
return _M_h.max_bucket_count(); }
1210 {
return _M_h.bucket_size(__n); }
1219 bucket(
const key_type& __key)
const
1220 {
return _M_h.bucket(__key); }
1222#ifdef __glibcxx_associative_heterogeneous_insertion
1223 template <__heterogeneous_hash_key<unordered_map> _Kt>
1225 bucket(
const _Kt& __key)
const
1226 {
return _M_h._M_bucket_tr(__key); }
1238 {
return _M_h.begin(__n); }
1249 {
return _M_h.begin(__n); }
1253 {
return _M_h.cbegin(__n); }
1264 {
return _M_h.end(__n); }
1275 {
return _M_h.end(__n); }
1279 {
return _M_h.cend(__n); }
1287 {
return _M_h.load_factor(); }
1293 {
return _M_h.max_load_factor(); }
1301 { _M_h.max_load_factor(__z); }
1312 { _M_h.rehash(__n); }
1323 { _M_h.reserve(__n); }
1325 template<
typename _Key1,
typename _Tp1,
typename _Hash1,
typename _Pred1,
1332#if __cpp_deduction_guides >= 201606
1334 template<
typename _InputIterator,
1335 typename _Hash = hash<__iter_key_t<_InputIterator>>,
1336 typename _Pred = equal_to<__iter_key_t<_InputIterator>>,
1337 typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>,
1338 typename = _RequireInputIter<_InputIterator>,
1339 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1340 typename = _RequireNotAllocator<_Pred>,
1341 typename = _RequireAllocator<_Allocator>>
1342 unordered_map(_InputIterator, _InputIterator,
1343 typename unordered_map<int, int>::size_type = {},
1344 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1346 __iter_val_t<_InputIterator>,
1347 _Hash, _Pred, _Allocator>;
1349 template<
typename _Key,
typename _Tp,
typename _Hash = hash<_Key>,
1350 typename _Pred = equal_to<_Key>,
1351 typename _Allocator = allocator<pair<const _Key, _Tp>>,
1352 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1353 typename = _RequireNotAllocator<_Pred>,
1354 typename = _RequireAllocator<_Allocator>>
1357 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1360 template<
typename _InputIterator,
typename _Allocator,
1361 typename = _RequireInputIter<_InputIterator>,
1362 typename = _RequireAllocator<_Allocator>>
1366 __iter_val_t<_InputIterator>,
1371 template<
typename _InputIterator,
typename _Allocator,
1372 typename = _RequireInputIter<_InputIterator>,
1373 typename = _RequireAllocator<_Allocator>>
1376 __iter_val_t<_InputIterator>,
1381 template<
typename _InputIterator,
typename _Hash,
typename _Allocator,
1382 typename = _RequireInputIter<_InputIterator>,
1383 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1384 typename = _RequireAllocator<_Allocator>>
1389 __iter_val_t<_InputIterator>, _Hash,
1392 template<
typename _Key,
typename _Tp,
typename _Allocator,
1393 typename = _RequireAllocator<_Allocator>>
1399 template<
typename _Key,
typename _Tp,
typename _Allocator,
1400 typename = _RequireAllocator<_Allocator>>
1404 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Allocator,
1405 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1406 typename = _RequireAllocator<_Allocator>>
1412#if __glibcxx_containers_ranges
1416 __allocator_like _Allocator =
1419 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1421 __detail::__range_mapped_type<_Rg>,
1422 _Hash, _Pred, _Allocator>;
1425 __allocator_like _Allocator>
1429 __detail::__range_mapped_type<_Rg>,
1435 __allocator_like _Allocator>
1438 __detail::__range_mapped_type<_Rg>,
1444 __not_allocator_like _Hash,
1445 __allocator_like _Allocator>
1449 __detail::__range_mapped_type<_Rg>,
1480 template<
typename _Key,
typename _Tp,
1486 typedef __ummap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Hashtable;
1515#ifdef __glibcxx_node_extract
1516 using node_type =
typename _Hashtable::node_type;
1536 : _M_h(__n, __hf, __eql, __a)
1552 template<
typename _InputIterator>
1558 : _M_h(__first, __last, __n, __hf, __eql, __a)
1582 const allocator_type& __a)
1583 : _M_h(__ummap._M_h, __a)
1592 const allocator_type& __a)
1593 noexcept(
noexcept(_Hashtable(
std::move(__ummap._M_h), __a)) )
1594 : _M_h(
std::
move(__ummap._M_h), __a)
1613 : _M_h(__l, __n, __hf, __eql, __a)
1621 const allocator_type& __a)
1622 : unordered_multimap(__n, __hf,
key_equal(), __a)
1627 template<
typename _InputIterator>
1633 template<
typename _InputIterator>
1640 template<
typename _InputIterator>
1666#if __glibcxx_containers_ranges
1680 template<__detail::__container_compatible_range<value_type> _Rg>
1686 : _M_h(__n, __hf, __eql, __a)
1691 template<__detail::__container_compatible_range<value_type> _Rg>
1696 template<__detail::__container_compatible_range<value_type> _Rg>
1702 template<__detail::__container_compatible_range<value_type> _Rg>
1738 {
return _M_h.get_allocator(); }
1743 _GLIBCXX_NODISCARD
bool
1745 {
return _M_h.empty(); }
1750 {
return _M_h.size(); }
1755 {
return _M_h.max_size(); }
1765 {
return _M_h.begin(); }
1774 {
return _M_h.begin(); }
1778 {
return _M_h.begin(); }
1787 {
return _M_h.end(); }
1796 {
return _M_h.end(); }
1800 {
return _M_h.end(); }
1820 template<
typename... _Args>
1847 template<
typename... _Args>
1864 {
return _M_h.insert(__x); }
1870 template<
typename _Pair>
1871 __enable_if_t<is_constructible<value_type, _Pair&&>::value,
iterator>
1898 {
return _M_h.insert(__hint, __x); }
1904 {
return _M_h.insert(__hint,
std::move(__x)); }
1906 template<
typename _Pair>
1907 __enable_if_t<is_constructible<value_type, _Pair&&>::value,
iterator>
1921 template<
typename _InputIterator>
1923 insert(_InputIterator __first, _InputIterator __last)
1924 { _M_h.insert(__first, __last); }
1936 { _M_h.insert(__l); }
1938#if __glibcxx_containers_ranges
1945 template<__detail::__container_compatible_range<value_type> _Rg>
1947 insert_range(_Rg&& __rg)
1949 auto __first = ranges::begin(__rg);
1950 const auto __last = ranges::end(__rg);
1951 if (__first == __last)
1955 _M_h._M_rehash_insert(
size_type(ranges::distance(__rg)));
1957 _M_h._M_rehash_insert(1);
1959 for (; __first != __last; ++__first)
1960 _M_h.emplace(*__first);
1964#ifdef __glibcxx_node_extract
1967 extract(const_iterator __pos)
1969 __glibcxx_assert(__pos !=
end());
1970 return _M_h.extract(__pos);
1976 {
return _M_h.extract(__key); }
1978#ifdef __glibcxx_associative_heterogeneous_erasure
1979 template <__heterogeneous_hash_key<unordered_multimap> _Kt>
1981 extract(_Kt&& __key)
1982 {
return _M_h._M_extract_tr(__key); }
1988 {
return _M_h._M_reinsert_node_multi(
cend(),
std::move(__nh)); }
1993 {
return _M_h._M_reinsert_node_multi(__hint,
std::move(__nh)); }
2012 {
return _M_h.erase(__position); }
2017 {
return _M_h.erase(__position); }
2034 {
return _M_h.erase(__x); }
2036#ifdef __glibcxx_associative_heterogeneous_erasure
2037 template <__heterogeneous_hash_key<unordered_multimap> _Kt>
2040 {
return _M_h._M_erase_tr(__x); }
2062 {
return _M_h.erase(__first, __last); }
2086 noexcept(
noexcept(_M_h.swap(__x._M_h)) )
2087 { _M_h.swap(__x._M_h); }
2089#ifdef __glibcxx_node_extract
2090 template<
typename,
typename,
typename>
2091 friend class std::_Hash_merge_helper;
2093 template<
typename _H2,
typename _P2>
2097 if constexpr (is_same_v<_H2, _Hash> && is_same_v<_P2, _Pred>)
2102 = _Hash_merge_helper<unordered_multimap, _H2, _P2>;
2103 _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source));
2106 template<
typename _H2,
typename _P2>
2108 merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
2111 = _Hash_merge_helper<unordered_multimap, _H2, _P2>;
2112 _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source));
2115 template<
typename _H2,
typename _P2>
2117 merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>& __source)
2120 = _Hash_merge_helper<unordered_multimap, _H2, _P2>;
2121 _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source));
2124 template<
typename _H2,
typename _P2>
2126 merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
2127 { merge(__source); }
2136 {
return _M_h.hash_function(); }
2142 {
return _M_h.key_eq(); }
2160 {
return _M_h.find(__x); }
2162#ifdef __glibcxx_generic_unordered_lookup
2163 template<
typename _Kt>
2165 find(
const _Kt& __x) ->
decltype(_M_h._M_find_tr(__x))
2166 {
return _M_h._M_find_tr(__x); }
2171 {
return _M_h.find(__x); }
2173#ifdef __glibcxx_generic_unordered_lookup
2174 template<
typename _Kt>
2176 find(
const _Kt& __x)
const ->
decltype(_M_h._M_find_tr(__x))
2177 {
return _M_h._M_find_tr(__x); }
2189 {
return _M_h.count(__x); }
2191#ifdef __glibcxx_generic_unordered_lookup
2192 template<
typename _Kt>
2194 count(
const _Kt& __x)
const ->
decltype(_M_h._M_count_tr(__x))
2195 {
return _M_h._M_count_tr(__x); }
2199#if __cplusplus > 201703L
2208 {
return _M_h.find(__x) != _M_h.end(); }
2210 template<
typename _Kt>
2213 ->
decltype(_M_h._M_find_tr(__x),
void(),
true)
2214 {
return _M_h._M_find_tr(__x) != _M_h.end(); }
2227 {
return _M_h.equal_range(__x); }
2229#ifdef __glibcxx_generic_unordered_lookup
2230 template<
typename _Kt>
2233 ->
decltype(_M_h._M_equal_range_tr(__x))
2234 {
return _M_h._M_equal_range_tr(__x); }
2239 {
return _M_h.equal_range(__x); }
2241#ifdef __glibcxx_generic_unordered_lookup
2242 template<
typename _Kt>
2245 ->
decltype(_M_h._M_equal_range_tr(__x))
2246 {
return _M_h._M_equal_range_tr(__x); }
2255 {
return _M_h.bucket_count(); }
2260 {
return _M_h.max_bucket_count(); }
2269 {
return _M_h.bucket_size(__n); }
2278 bucket(
const key_type& __key)
const
2279 {
return _M_h.bucket(__key); }
2281#ifdef __glibcxx_associative_heterogeneous_insertion
2282 template <__heterogeneous_hash_key<unordered_multimap> _Kt>
2284 bucket(
const _Kt& __key)
const
2285 {
return _M_h._M_bucket_tr(__key); }
2297 {
return _M_h.begin(__n); }
2308 {
return _M_h.begin(__n); }
2312 {
return _M_h.cbegin(__n); }
2323 {
return _M_h.end(__n); }
2334 {
return _M_h.end(__n); }
2338 {
return _M_h.cend(__n); }
2346 {
return _M_h.load_factor(); }
2352 {
return _M_h.max_load_factor(); }
2360 { _M_h.max_load_factor(__z); }
2371 { _M_h.rehash(__n); }
2382 { _M_h.reserve(__n); }
2384 template<
typename _Key1,
typename _Tp1,
typename _Hash1,
typename _Pred1,
2388 _Hash1, _Pred1, _Alloc1>&,
2390 _Hash1, _Pred1, _Alloc1>&);
2393#if __cpp_deduction_guides >= 201606
2395 template<
typename _InputIterator,
2396 typename _Hash = hash<__iter_key_t<_InputIterator>>,
2397 typename _Pred = equal_to<__iter_key_t<_InputIterator>>,
2398 typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>,
2399 typename = _RequireInputIter<_InputIterator>,
2400 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2401 typename = _RequireNotAllocator<_Pred>,
2402 typename = _RequireAllocator<_Allocator>>
2403 unordered_multimap(_InputIterator, _InputIterator,
2404 unordered_multimap<int, int>::size_type = {},
2405 _Hash = _Hash(), _Pred = _Pred(),
2406 _Allocator = _Allocator())
2408 __iter_val_t<_InputIterator>, _Hash, _Pred,
2411 template<
typename _Key,
typename _Tp,
typename _Hash = hash<_Key>,
2412 typename _Pred = equal_to<_Key>,
2413 typename _Allocator = allocator<pair<const _Key, _Tp>>,
2414 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2415 typename = _RequireNotAllocator<_Pred>,
2416 typename = _RequireAllocator<_Allocator>>
2419 _Hash = _Hash(), _Pred = _Pred(),
2420 _Allocator = _Allocator())
2423 template<
typename _InputIterator,
typename _Allocator,
2424 typename = _RequireInputIter<_InputIterator>,
2425 typename = _RequireAllocator<_Allocator>>
2429 __iter_val_t<_InputIterator>,
2433 template<
typename _InputIterator,
typename _Allocator,
2434 typename = _RequireInputIter<_InputIterator>,
2435 typename = _RequireAllocator<_Allocator>>
2438 __iter_val_t<_InputIterator>,
2442 template<
typename _InputIterator,
typename _Hash,
typename _Allocator,
2443 typename = _RequireInputIter<_InputIterator>,
2444 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2445 typename = _RequireAllocator<_Allocator>>
2450 __iter_val_t<_InputIterator>, _Hash,
2453 template<
typename _Key,
typename _Tp,
typename _Allocator,
2454 typename = _RequireAllocator<_Allocator>>
2460 template<
typename _Key,
typename _Tp,
typename _Allocator,
2461 typename = _RequireAllocator<_Allocator>>
2465 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Allocator,
2466 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2467 typename = _RequireAllocator<_Allocator>>
2473#if __glibcxx_containers_ranges
2477 __allocator_like _Allocator =
2481 _Hash = _Hash(), _Pred = _Pred(),
2482 _Allocator = _Allocator())
2484 __detail::__range_mapped_type<_Rg>,
2485 _Hash, _Pred, _Allocator>;
2488 __allocator_like _Allocator>
2492 __detail::__range_mapped_type<_Rg>,
2498 __allocator_like _Allocator>
2501 __detail::__range_mapped_type<_Rg>,
2507 __not_allocator_like _Hash,
2508 __allocator_like _Allocator>
2513 __detail::__range_mapped_type<_Rg>,
2519 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2523 noexcept(
noexcept(__x.swap(__y)))
2526 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2530 noexcept(
noexcept(__x.swap(__y)))
2533 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2537 {
return __x._M_h._M_equal(__y._M_h); }
2539#if __cpp_impl_three_way_comparison < 201907L
2540 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2544 {
return !(__x == __y); }
2547 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2551 {
return __x._M_h._M_equal(__y._M_h); }
2553#if __cpp_impl_three_way_comparison < 201907L
2554 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2558 {
return !(__x == __y); }
2561_GLIBCXX_END_NAMESPACE_CONTAINER
2563#ifdef __glibcxx_node_extract
2565 template<
typename _Key,
typename _Val,
typename _Hash1,
typename _Eq1,
2566 typename _Alloc,
typename _Hash2,
typename _Eq2>
2567 struct _Hash_merge_helper<
2568 _GLIBCXX_STD_C::
unordered_map<_Key, _Val, _Hash1, _Eq1, _Alloc>,
2572 template<
typename... _Tp>
2573 using unordered_map = _GLIBCXX_STD_C::unordered_map<_Tp...>;
2574 template<
typename... _Tp>
2575 using unordered_multimap = _GLIBCXX_STD_C::unordered_multimap<_Tp...>;
2577 friend unordered_map<_Key, _Val, _Hash1, _Eq1, _Alloc>;
2580 _S_get_table(unordered_map<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
2581 {
return __map._M_h; }
2584 _S_get_table(unordered_multimap<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
2585 {
return __map._M_h; }
2589 template<
typename _Key,
typename _Val,
typename _Hash1,
typename _Eq1,
2590 typename _Alloc,
typename _Hash2,
typename _Eq2>
2591 struct _Hash_merge_helper<
2596 template<
typename... _Tp>
2597 using unordered_map = _GLIBCXX_STD_C::unordered_map<_Tp...>;
2598 template<
typename... _Tp>
2599 using unordered_multimap = _GLIBCXX_STD_C::unordered_multimap<_Tp...>;
2601 friend unordered_multimap<_Key, _Val, _Hash1, _Eq1, _Alloc>;
2604 _S_get_table(unordered_map<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
2605 {
return __map._M_h; }
2608 _S_get_table(unordered_multimap<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
2609 {
return __map._M_h; }
2613_GLIBCXX_END_NAMESPACE_VERSION
pair(_T1, _T2) -> pair< _T1, _T2 >
Two pairs are equal iff their members are equal.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
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 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
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.
__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
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
iterator emplace(_Args &&... __args)
Attempts to build and insert a std::pair into the unordered_multimap.
bool contains(const key_type &__x) const
Finds whether an element with the given key exists.
_Hashtable::const_reference const_reference
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
_Hashtable::local_iterator local_iterator
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.
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
_Hashtable::allocator_type allocator_type
const_local_iterator begin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
_Hashtable::const_local_iterator const_local_iterator
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
_Hashtable::size_type size_type
_Hashtable::const_pointer const_pointer
__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
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
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.
_Hashtable::key_equal key_equal
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.
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
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.
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.
unordered_map & operator=(initializer_list< value_type > __l)
Unordered_map list assignment operator.
_Hashtable::const_pointer const_pointer
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.
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.
_Hashtable::reference reference
iterator insert(const_iterator __hint, const value_type &__x)
Attempts to insert a std::pair into the unordered_map.
_Hashtable::allocator_type allocator_type
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 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
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
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.
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
_Hashtable::key_equal key_equal
_Hashtable::local_iterator local_iterator
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
unordered_map(const allocator_type &__a)
Creates an unordered_map with no elements.
_Hashtable::key_type key_type
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.
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
_Hashtable::size_type size_type
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
_Hashtable::const_local_iterator const_local_iterator
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.
_Hashtable::value_type value_type
void rehash(size_type __n)
May rehash the unordered_map.
const_iterator cbegin() const noexcept
[range.sized] The sized_range concept.
A range for which ranges::begin returns an input iterator.
A range for which ranges::begin returns a forward iterator.