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>
485 template<
typename... _Args>
490#ifdef __glibcxx_node_extract
493 extract(const_iterator __pos)
495 __glibcxx_assert(__pos !=
end());
496 return _M_h.extract(__pos);
502 {
return _M_h.extract(__key); }
507 {
return _M_h._M_reinsert_node(
std::move(__nh)); }
512 {
return _M_h._M_reinsert_node(
std::move(__nh)).position; }
515#ifdef __glibcxx_unordered_map_try_emplace
538 template <
typename... _Args>
540 try_emplace(
const key_type& __k, _Args&&... __args)
546 template <
typename... _Args>
548 try_emplace(
key_type&& __k, _Args&&... __args)
582 template <
typename... _Args>
587 return _M_h.try_emplace(__hint, __k,
592 template <
typename... _Args>
596 return _M_h.try_emplace(__hint,
std::move(__k),
621 {
return _M_h.insert(__x); }
629 template<
typename _Pair>
630 __enable_if_t<is_constructible<value_type, _Pair&&>::value,
660 {
return _M_h.insert(__hint, __x); }
666 {
return _M_h.insert(__hint,
std::move(__x)); }
668 template<
typename _Pair>
669 __enable_if_t<is_constructible<value_type, _Pair&&>::value,
iterator>
683 template<
typename _InputIterator>
685 insert(_InputIterator __first, _InputIterator __last)
686 { _M_h.insert(__first, __last); }
697 { _M_h.insert(__l); }
699#if __glibcxx_containers_ranges
706 template<__detail::__container_compatible_range<value_type> _Rg>
708 insert_range(_Rg&& __rg)
710 auto __first = ranges::begin(__rg);
711 const auto __last = ranges::end(__rg);
712 for (; __first != __last; ++__first)
713 _M_h.emplace(*__first);
717#ifdef __glibcxx_unordered_map_try_emplace
738 template <
typename _Obj>
740 insert_or_assign(
const key_type& __k, _Obj&& __obj)
742 auto __ret = _M_h.try_emplace(
cend(), __k,
750 template <
typename _Obj>
752 insert_or_assign(
key_type&& __k, _Obj&& __obj)
787 template <
typename _Obj>
799 template <
typename _Obj>
803 auto __ret = _M_h.try_emplace(__hint,
std::move(__k),
827 {
return _M_h.erase(__position); }
832 {
return _M_h.erase(__position); }
849 {
return _M_h.erase(__x); }
867 {
return _M_h.erase(__first, __last); }
891 noexcept(
noexcept(_M_h.swap(__x._M_h)) )
892 { _M_h.swap(__x._M_h); }
894#ifdef __glibcxx_node_extract
895 template<
typename,
typename,
typename>
896 friend class std::_Hash_merge_helper;
898 template<
typename _H2,
typename _P2>
902 if constexpr (is_same_v<_H2, _Hash> && is_same_v<_P2, _Pred>)
906 using _Merge_helper = _Hash_merge_helper<unordered_map, _H2, _P2>;
907 _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source));
910 template<
typename _H2,
typename _P2>
912 merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
914 using _Merge_helper = _Hash_merge_helper<unordered_map, _H2, _P2>;
915 _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source));
918 template<
typename _H2,
typename _P2>
920 merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>& __source)
922 using _Merge_helper = _Hash_merge_helper<unordered_map, _H2, _P2>;
923 _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source));
926 template<
typename _H2,
typename _P2>
928 merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
938 {
return _M_h.hash_function(); }
944 {
return _M_h.key_eq(); }
962 {
return _M_h.find(__x); }
964#if __cplusplus > 201703L
965 template<
typename _Kt>
967 find(
const _Kt& __x) ->
decltype(_M_h._M_find_tr(__x))
968 {
return _M_h._M_find_tr(__x); }
973 {
return _M_h.find(__x); }
975#if __cplusplus > 201703L
976 template<
typename _Kt>
978 find(
const _Kt& __x)
const ->
decltype(_M_h._M_find_tr(__x))
979 {
return _M_h._M_find_tr(__x); }
995 {
return _M_h.count(__x); }
997#if __cplusplus > 201703L
998 template<
typename _Kt>
1000 count(
const _Kt& __x)
const ->
decltype(_M_h._M_count_tr(__x))
1001 {
return _M_h._M_count_tr(__x); }
1005#if __cplusplus > 201703L
1014 {
return _M_h.find(__x) != _M_h.end(); }
1016 template<
typename _Kt>
1019 ->
decltype(_M_h._M_find_tr(__x),
void(),
true)
1020 {
return _M_h._M_find_tr(__x) != _M_h.end(); }
1035 {
return _M_h.equal_range(__x); }
1037#if __cplusplus > 201703L
1038 template<
typename _Kt>
1041 ->
decltype(_M_h._M_equal_range_tr(__x))
1042 {
return _M_h._M_equal_range_tr(__x); }
1047 {
return _M_h.equal_range(__x); }
1049#if __cplusplus > 201703L
1050 template<
typename _Kt>
1053 ->
decltype(_M_h._M_equal_range_tr(__x))
1054 {
return _M_h._M_equal_range_tr(__x); }
1073 {
return _M_h[__k]; }
1090 {
return _M_h.at(__k); }
1094 {
return _M_h.at(__k); }
1102 {
return _M_h.bucket_count(); }
1107 {
return _M_h.max_bucket_count(); }
1116 {
return _M_h.bucket_size(__n); }
1124 bucket(
const key_type& __key)
const
1125 {
return _M_h.bucket(__key); }
1135 {
return _M_h.begin(__n); }
1146 {
return _M_h.begin(__n); }
1150 {
return _M_h.cbegin(__n); }
1161 {
return _M_h.end(__n); }
1172 {
return _M_h.end(__n); }
1176 {
return _M_h.cend(__n); }
1184 {
return _M_h.load_factor(); }
1190 {
return _M_h.max_load_factor(); }
1198 { _M_h.max_load_factor(__z); }
1209 { _M_h.rehash(__n); }
1220 { _M_h.reserve(__n); }
1222 template<
typename _Key1,
typename _Tp1,
typename _Hash1,
typename _Pred1,
1229#if __cpp_deduction_guides >= 201606
1231 template<
typename _InputIterator,
1232 typename _Hash = hash<__iter_key_t<_InputIterator>>,
1233 typename _Pred = equal_to<__iter_key_t<_InputIterator>>,
1234 typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>,
1235 typename = _RequireInputIter<_InputIterator>,
1236 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1237 typename = _RequireNotAllocator<_Pred>,
1238 typename = _RequireAllocator<_Allocator>>
1239 unordered_map(_InputIterator, _InputIterator,
1240 typename unordered_map<int, int>::size_type = {},
1241 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1243 __iter_val_t<_InputIterator>,
1244 _Hash, _Pred, _Allocator>;
1246 template<
typename _Key,
typename _Tp,
typename _Hash = hash<_Key>,
1247 typename _Pred = equal_to<_Key>,
1248 typename _Allocator = allocator<pair<const _Key, _Tp>>,
1249 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1250 typename = _RequireNotAllocator<_Pred>,
1251 typename = _RequireAllocator<_Allocator>>
1254 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1257 template<
typename _InputIterator,
typename _Allocator,
1258 typename = _RequireInputIter<_InputIterator>,
1259 typename = _RequireAllocator<_Allocator>>
1263 __iter_val_t<_InputIterator>,
1268 template<
typename _InputIterator,
typename _Allocator,
1269 typename = _RequireInputIter<_InputIterator>,
1270 typename = _RequireAllocator<_Allocator>>
1273 __iter_val_t<_InputIterator>,
1278 template<
typename _InputIterator,
typename _Hash,
typename _Allocator,
1279 typename = _RequireInputIter<_InputIterator>,
1280 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1281 typename = _RequireAllocator<_Allocator>>
1286 __iter_val_t<_InputIterator>, _Hash,
1289 template<
typename _Key,
typename _Tp,
typename _Allocator,
1290 typename = _RequireAllocator<_Allocator>>
1296 template<
typename _Key,
typename _Tp,
typename _Allocator,
1297 typename = _RequireAllocator<_Allocator>>
1301 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Allocator,
1302 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1303 typename = _RequireAllocator<_Allocator>>
1309#if __glibcxx_containers_ranges
1310 template<ranges::input_range _Rg,
1313 __allocator_like _Allocator =
1316 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1318 __detail::__range_mapped_type<_Rg>,
1319 _Hash, _Pred, _Allocator>;
1321 template<ranges::input_range _Rg,
1322 __allocator_like _Allocator>
1326 __detail::__range_mapped_type<_Rg>,
1331 template<ranges::input_range _Rg,
1332 __allocator_like _Allocator>
1335 __detail::__range_mapped_type<_Rg>,
1340 template<ranges::input_range _Rg,
1341 __not_allocator_like _Hash,
1342 __allocator_like _Allocator>
1346 __detail::__range_mapped_type<_Rg>,
1377 template<
typename _Key,
typename _Tp,
1383 typedef __ummap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Hashtable;
1412#ifdef __glibcxx_node_extract
1413 using node_type =
typename _Hashtable::node_type;
1433 : _M_h(__n, __hf, __eql, __a)
1449 template<
typename _InputIterator>
1455 : _M_h(__first, __last, __n, __hf, __eql, __a)
1479 const allocator_type& __a)
1480 : _M_h(__ummap._M_h, __a)
1489 const allocator_type& __a)
1490 noexcept(
noexcept(_Hashtable(
std::move(__ummap._M_h), __a)) )
1491 : _M_h(
std::
move(__ummap._M_h), __a)
1510 : _M_h(__l, __n, __hf, __eql, __a)
1518 const allocator_type& __a)
1519 : unordered_multimap(__n, __hf,
key_equal(), __a)
1524 template<
typename _InputIterator>
1530 template<
typename _InputIterator>
1537 template<
typename _InputIterator>
1563#if __glibcxx_containers_ranges
1577 template<__detail::__container_compatible_range<value_type> _Rg>
1583 : _M_h(__n, __hf, __eql, __a)
1588 template<__detail::__container_compatible_range<value_type> _Rg>
1593 template<__detail::__container_compatible_range<value_type> _Rg>
1599 template<__detail::__container_compatible_range<value_type> _Rg>
1635 {
return _M_h.get_allocator(); }
1640 _GLIBCXX_NODISCARD
bool
1642 {
return _M_h.empty(); }
1647 {
return _M_h.size(); }
1652 {
return _M_h.max_size(); }
1662 {
return _M_h.begin(); }
1671 {
return _M_h.begin(); }
1675 {
return _M_h.begin(); }
1684 {
return _M_h.end(); }
1693 {
return _M_h.end(); }
1697 {
return _M_h.end(); }
1717 template<
typename... _Args>
1744 template<
typename... _Args>
1761 {
return _M_h.insert(__x); }
1767 template<
typename _Pair>
1768 __enable_if_t<is_constructible<value_type, _Pair&&>::value,
iterator>
1795 {
return _M_h.insert(__hint, __x); }
1801 {
return _M_h.insert(__hint,
std::move(__x)); }
1803 template<
typename _Pair>
1804 __enable_if_t<is_constructible<value_type, _Pair&&>::value,
iterator>
1818 template<
typename _InputIterator>
1820 insert(_InputIterator __first, _InputIterator __last)
1821 { _M_h.insert(__first, __last); }
1833 { _M_h.insert(__l); }
1835#if __glibcxx_containers_ranges
1842 template<__detail::__container_compatible_range<value_type> _Rg>
1844 insert_range(_Rg&& __rg)
1846 auto __first = ranges::begin(__rg);
1847 const auto __last = ranges::end(__rg);
1848 if (__first == __last)
1851 if constexpr (ranges::forward_range<_Rg> || ranges::sized_range<_Rg>)
1852 _M_h._M_rehash_insert(
size_type(ranges::distance(__rg)));
1854 _M_h._M_rehash_insert(1);
1856 for (; __first != __last; ++__first)
1857 _M_h.emplace(*__first);
1861#ifdef __glibcxx_node_extract
1864 extract(const_iterator __pos)
1866 __glibcxx_assert(__pos !=
end());
1867 return _M_h.extract(__pos);
1873 {
return _M_h.extract(__key); }
1878 {
return _M_h._M_reinsert_node_multi(
cend(),
std::move(__nh)); }
1883 {
return _M_h._M_reinsert_node_multi(__hint,
std::move(__nh)); }
1902 {
return _M_h.erase(__position); }
1907 {
return _M_h.erase(__position); }
1923 {
return _M_h.erase(__x); }
1942 {
return _M_h.erase(__first, __last); }
1966 noexcept(
noexcept(_M_h.swap(__x._M_h)) )
1967 { _M_h.swap(__x._M_h); }
1969#ifdef __glibcxx_node_extract
1970 template<
typename,
typename,
typename>
1971 friend class std::_Hash_merge_helper;
1973 template<
typename _H2,
typename _P2>
1977 if constexpr (is_same_v<_H2, _Hash> && is_same_v<_P2, _Pred>)
1982 = _Hash_merge_helper<unordered_multimap, _H2, _P2>;
1983 _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source));
1986 template<
typename _H2,
typename _P2>
1988 merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
1991 = _Hash_merge_helper<unordered_multimap, _H2, _P2>;
1992 _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source));
1995 template<
typename _H2,
typename _P2>
1997 merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>& __source)
2000 = _Hash_merge_helper<unordered_multimap, _H2, _P2>;
2001 _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source));
2004 template<
typename _H2,
typename _P2>
2006 merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
2007 { merge(__source); }
2016 {
return _M_h.hash_function(); }
2022 {
return _M_h.key_eq(); }
2040 {
return _M_h.find(__x); }
2042#if __cplusplus > 201703L
2043 template<
typename _Kt>
2045 find(
const _Kt& __x) ->
decltype(_M_h._M_find_tr(__x))
2046 {
return _M_h._M_find_tr(__x); }
2051 {
return _M_h.find(__x); }
2053#if __cplusplus > 201703L
2054 template<
typename _Kt>
2056 find(
const _Kt& __x)
const ->
decltype(_M_h._M_find_tr(__x))
2057 {
return _M_h._M_find_tr(__x); }
2069 {
return _M_h.count(__x); }
2071#if __cplusplus > 201703L
2072 template<
typename _Kt>
2074 count(
const _Kt& __x)
const ->
decltype(_M_h._M_count_tr(__x))
2075 {
return _M_h._M_count_tr(__x); }
2079#if __cplusplus > 201703L
2088 {
return _M_h.find(__x) != _M_h.end(); }
2090 template<
typename _Kt>
2093 ->
decltype(_M_h._M_find_tr(__x),
void(),
true)
2094 {
return _M_h._M_find_tr(__x) != _M_h.end(); }
2107 {
return _M_h.equal_range(__x); }
2109#if __cplusplus > 201703L
2110 template<
typename _Kt>
2113 ->
decltype(_M_h._M_equal_range_tr(__x))
2114 {
return _M_h._M_equal_range_tr(__x); }
2119 {
return _M_h.equal_range(__x); }
2121#if __cplusplus > 201703L
2122 template<
typename _Kt>
2125 ->
decltype(_M_h._M_equal_range_tr(__x))
2126 {
return _M_h._M_equal_range_tr(__x); }
2135 {
return _M_h.bucket_count(); }
2140 {
return _M_h.max_bucket_count(); }
2149 {
return _M_h.bucket_size(__n); }
2157 bucket(
const key_type& __key)
const
2158 {
return _M_h.bucket(__key); }
2168 {
return _M_h.begin(__n); }
2179 {
return _M_h.begin(__n); }
2183 {
return _M_h.cbegin(__n); }
2194 {
return _M_h.end(__n); }
2205 {
return _M_h.end(__n); }
2209 {
return _M_h.cend(__n); }
2217 {
return _M_h.load_factor(); }
2223 {
return _M_h.max_load_factor(); }
2231 { _M_h.max_load_factor(__z); }
2242 { _M_h.rehash(__n); }
2253 { _M_h.reserve(__n); }
2255 template<
typename _Key1,
typename _Tp1,
typename _Hash1,
typename _Pred1,
2259 _Hash1, _Pred1, _Alloc1>&,
2261 _Hash1, _Pred1, _Alloc1>&);
2264#if __cpp_deduction_guides >= 201606
2266 template<
typename _InputIterator,
2267 typename _Hash = hash<__iter_key_t<_InputIterator>>,
2268 typename _Pred = equal_to<__iter_key_t<_InputIterator>>,
2269 typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>,
2270 typename = _RequireInputIter<_InputIterator>,
2271 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2272 typename = _RequireNotAllocator<_Pred>,
2273 typename = _RequireAllocator<_Allocator>>
2274 unordered_multimap(_InputIterator, _InputIterator,
2275 unordered_multimap<int, int>::size_type = {},
2276 _Hash = _Hash(), _Pred = _Pred(),
2277 _Allocator = _Allocator())
2279 __iter_val_t<_InputIterator>, _Hash, _Pred,
2282 template<
typename _Key,
typename _Tp,
typename _Hash = hash<_Key>,
2283 typename _Pred = equal_to<_Key>,
2284 typename _Allocator = allocator<pair<const _Key, _Tp>>,
2285 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2286 typename = _RequireNotAllocator<_Pred>,
2287 typename = _RequireAllocator<_Allocator>>
2290 _Hash = _Hash(), _Pred = _Pred(),
2291 _Allocator = _Allocator())
2294 template<
typename _InputIterator,
typename _Allocator,
2295 typename = _RequireInputIter<_InputIterator>,
2296 typename = _RequireAllocator<_Allocator>>
2300 __iter_val_t<_InputIterator>,
2304 template<
typename _InputIterator,
typename _Allocator,
2305 typename = _RequireInputIter<_InputIterator>,
2306 typename = _RequireAllocator<_Allocator>>
2309 __iter_val_t<_InputIterator>,
2313 template<
typename _InputIterator,
typename _Hash,
typename _Allocator,
2314 typename = _RequireInputIter<_InputIterator>,
2315 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2316 typename = _RequireAllocator<_Allocator>>
2321 __iter_val_t<_InputIterator>, _Hash,
2324 template<
typename _Key,
typename _Tp,
typename _Allocator,
2325 typename = _RequireAllocator<_Allocator>>
2331 template<
typename _Key,
typename _Tp,
typename _Allocator,
2332 typename = _RequireAllocator<_Allocator>>
2336 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Allocator,
2337 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2338 typename = _RequireAllocator<_Allocator>>
2344#if __glibcxx_containers_ranges
2345 template<ranges::input_range _Rg,
2348 __allocator_like _Allocator =
2352 _Hash = _Hash(), _Pred = _Pred(),
2353 _Allocator = _Allocator())
2355 __detail::__range_mapped_type<_Rg>,
2356 _Hash, _Pred, _Allocator>;
2358 template<ranges::input_range _Rg,
2359 __allocator_like _Allocator>
2363 __detail::__range_mapped_type<_Rg>,
2368 template<ranges::input_range _Rg,
2369 __allocator_like _Allocator>
2372 __detail::__range_mapped_type<_Rg>,
2377 template<ranges::input_range _Rg,
2378 __not_allocator_like _Hash,
2379 __allocator_like _Allocator>
2384 __detail::__range_mapped_type<_Rg>,
2390 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2394 noexcept(
noexcept(__x.swap(__y)))
2397 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2401 noexcept(
noexcept(__x.swap(__y)))
2404 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2408 {
return __x._M_h._M_equal(__y._M_h); }
2410#if __cpp_impl_three_way_comparison < 201907L
2411 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2415 {
return !(__x == __y); }
2418 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2422 {
return __x._M_h._M_equal(__y._M_h); }
2424#if __cpp_impl_three_way_comparison < 201907L
2425 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2429 {
return !(__x == __y); }
2432_GLIBCXX_END_NAMESPACE_CONTAINER
2434#ifdef __glibcxx_node_extract
2436 template<
typename _Key,
typename _Val,
typename _Hash1,
typename _Eq1,
2437 typename _Alloc,
typename _Hash2,
typename _Eq2>
2438 struct _Hash_merge_helper<
2439 _GLIBCXX_STD_C::
unordered_map<_Key, _Val, _Hash1, _Eq1, _Alloc>,
2443 template<
typename... _Tp>
2444 using unordered_map = _GLIBCXX_STD_C::unordered_map<_Tp...>;
2445 template<
typename... _Tp>
2446 using unordered_multimap = _GLIBCXX_STD_C::unordered_multimap<_Tp...>;
2448 friend unordered_map<_Key, _Val, _Hash1, _Eq1, _Alloc>;
2451 _S_get_table(unordered_map<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
2452 {
return __map._M_h; }
2455 _S_get_table(unordered_multimap<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
2456 {
return __map._M_h; }
2460 template<
typename _Key,
typename _Val,
typename _Hash1,
typename _Eq1,
2461 typename _Alloc,
typename _Hash2,
typename _Eq2>
2462 struct _Hash_merge_helper<
2467 template<
typename... _Tp>
2468 using unordered_map = _GLIBCXX_STD_C::unordered_map<_Tp...>;
2469 template<
typename... _Tp>
2470 using unordered_multimap = _GLIBCXX_STD_C::unordered_multimap<_Tp...>;
2472 friend unordered_multimap<_Key, _Val, _Hash1, _Eq1, _Alloc>;
2475 _S_get_table(unordered_map<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
2476 {
return __map._M_h; }
2479 _S_get_table(unordered_multimap<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
2480 {
return __map._M_h; }
2484_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
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
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.
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
_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.
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
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.
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
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
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.
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
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.
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 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
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.
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
_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
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
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