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); }
504#ifdef __glibcxx_associative_heterogeneous_erasure
505 template <__heterogeneous_hash_key<unordered_map> _Kt>
508 {
return _M_h._M_extract_tr(__key); }
514 {
return _M_h._M_reinsert_node(
std::move(__nh)); }
519 {
return _M_h._M_reinsert_node(
std::move(__nh)).position; }
522#ifdef __glibcxx_unordered_map_try_emplace
546 template <
typename... _Args>
548 try_emplace(
const key_type& __k, _Args&&... __args)
554 template <
typename... _Args>
556 try_emplace(
key_type&& __k, _Args&&... __args)
562#ifdef __glibcxx_associative_heterogeneous_insertion
563 template <__heterogeneous_hash_key<unordered_map> _Kt,
typename ..._Args>
565 try_emplace(_Kt&& __k, _Args&&... __args)
567 return _M_h.try_emplace(
cend(),
602 template <
typename... _Args>
607 return _M_h.try_emplace(__hint, __k,
612 template <
typename... _Args>
616 return _M_h.try_emplace(__hint,
std::move(__k),
620#ifdef __glibcxx_associative_heterogeneous_insertion
621 template <__heterogeneous_hash_key<unordered_map> _Kt,
typename ..._Args>
625 return _M_h.try_emplace(__hint,
652 {
return _M_h.insert(__x); }
660 template<
typename _Pair>
661 __enable_if_t<is_constructible<value_type, _Pair&&>::value,
691 {
return _M_h.insert(__hint, __x); }
697 {
return _M_h.insert(__hint,
std::move(__x)); }
699 template<
typename _Pair>
700 __enable_if_t<is_constructible<value_type, _Pair&&>::value,
iterator>
714 template<
typename _InputIterator>
716 insert(_InputIterator __first, _InputIterator __last)
717 { _M_h.insert(__first, __last); }
728 { _M_h.insert(__l); }
730#if __glibcxx_containers_ranges
737 template<__detail::__container_compatible_range<value_type> _Rg>
739 insert_range(_Rg&& __rg)
741 auto __first = ranges::begin(__rg);
742 const auto __last = ranges::end(__rg);
743 for (; __first != __last; ++__first)
744 _M_h.emplace(*__first);
748#ifdef __glibcxx_unordered_map_try_emplace
770 template <
typename _Obj>
772 insert_or_assign(
const key_type& __k, _Obj&& __obj)
774 auto __ret = _M_h.try_emplace(
cend(), __k,
782 template <
typename _Obj>
784 insert_or_assign(
key_type&& __k, _Obj&& __obj)
793#ifdef __glibcxx_associative_heterogeneous_insertion
794 template <__heterogeneous_hash_key<unordered_map> _Kt,
typename _Obj>
796 insert_or_assign(_Kt&& __k, _Obj&& __obj)
798 auto __ret = _M_h.try_emplace(
834 template <
typename _Obj>
846 template <
typename _Obj>
850 auto __ret = _M_h.try_emplace(__hint,
std::move(__k),
857#ifdef __glibcxx_associative_heterogeneous_insertion
858 template <__heterogeneous_hash_key<unordered_map> _Kt,
typename _Obj>
862 auto __ret = _M_h.try_emplace(__hint,
888 {
return _M_h.erase(__position); }
893 {
return _M_h.erase(__position); }
911 {
return _M_h.erase(__x); }
913#ifdef __glibcxx_associative_heterogeneous_erasure
914 template <__heterogeneous_hash_key<unordered_map> _Kt>
917 {
return _M_h._M_erase_tr(__x); }
937 {
return _M_h.erase(__first, __last); }
961 noexcept(
noexcept(_M_h.swap(__x._M_h)) )
962 { _M_h.swap(__x._M_h); }
964#ifdef __glibcxx_node_extract
965 template<
typename,
typename,
typename>
966 friend class std::_Hash_merge_helper;
968 template<
typename _H2,
typename _P2>
972 if constexpr (is_same_v<_H2, _Hash> && is_same_v<_P2, _Pred>)
976 using _Merge_helper = _Hash_merge_helper<unordered_map, _H2, _P2>;
977 _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source));
980 template<
typename _H2,
typename _P2>
982 merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
984 using _Merge_helper = _Hash_merge_helper<unordered_map, _H2, _P2>;
985 _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source));
988 template<
typename _H2,
typename _P2>
990 merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>& __source)
992 using _Merge_helper = _Hash_merge_helper<unordered_map, _H2, _P2>;
993 _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source));
996 template<
typename _H2,
typename _P2>
998 merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
1008 {
return _M_h.hash_function(); }
1014 {
return _M_h.key_eq(); }
1032 {
return _M_h.find(__x); }
1034#ifdef __glibcxx_generic_unordered_lookup
1035 template<
typename _Kt>
1037 find(
const _Kt& __x) ->
decltype(_M_h._M_find_tr(__x))
1038 {
return _M_h._M_find_tr(__x); }
1043 {
return _M_h.find(__x); }
1045#ifdef __glibcxx_generic_unordered_lookup
1046 template<
typename _Kt>
1048 find(
const _Kt& __x)
const ->
decltype(_M_h._M_find_tr(__x))
1049 {
return _M_h._M_find_tr(__x); }
1065 {
return _M_h.count(__x); }
1067#ifdef __glibcxx_generic_unordered_lookup
1068 template<
typename _Kt>
1070 count(
const _Kt& __x)
const ->
decltype(_M_h._M_count_tr(__x))
1071 {
return _M_h._M_count_tr(__x); }
1075#if __cplusplus > 201703L
1084 {
return _M_h.find(__x) != _M_h.end(); }
1086 template<
typename _Kt>
1089 ->
decltype(_M_h._M_find_tr(__x),
void(),
true)
1090 {
return _M_h._M_find_tr(__x) != _M_h.end(); }
1105 {
return _M_h.equal_range(__x); }
1107#ifdef __glibcxx_generic_unordered_lookup
1108 template<
typename _Kt>
1111 ->
decltype(_M_h._M_equal_range_tr(__x))
1112 {
return _M_h._M_equal_range_tr(__x); }
1117 {
return _M_h.equal_range(__x); }
1119#ifdef __glibcxx_generic_unordered_lookup
1120 template<
typename _Kt>
1123 ->
decltype(_M_h._M_equal_range_tr(__x))
1124 {
return _M_h._M_equal_range_tr(__x); }
1143 {
return _M_h[__k]; }
1149#ifdef __glibcxx_associative_heterogeneous_insertion
1150 template <__heterogeneous_hash_key<unordered_map> _Kt>
1169 {
return _M_h.at(__k); }
1171#ifdef __glibcxx_associative_heterogeneous_insertion
1172 template <__heterogeneous_hash_key<unordered_map> _Kt>
1175 {
return _M_h._M_at_tr(__k); }
1180 {
return _M_h.at(__k); }
1182#ifdef __glibcxx_associative_heterogeneous_insertion
1183 template <__heterogeneous_hash_key<unordered_map> _Kt>
1186 {
return _M_h._M_at_tr(__k); }
1195 {
return _M_h.bucket_count(); }
1200 {
return _M_h.max_bucket_count(); }
1209 {
return _M_h.bucket_size(__n); }
1218 bucket(
const key_type& __key)
const
1219 {
return _M_h.bucket(__key); }
1221#ifdef __glibcxx_associative_heterogeneous_insertion
1222 template <__heterogeneous_hash_key<unordered_map> _Kt>
1224 bucket(
const _Kt& __key)
const
1225 {
return _M_h._M_bucket_tr(__key); }
1237 {
return _M_h.begin(__n); }
1248 {
return _M_h.begin(__n); }
1252 {
return _M_h.cbegin(__n); }
1263 {
return _M_h.end(__n); }
1274 {
return _M_h.end(__n); }
1278 {
return _M_h.cend(__n); }
1286 {
return _M_h.load_factor(); }
1292 {
return _M_h.max_load_factor(); }
1300 { _M_h.max_load_factor(__z); }
1311 { _M_h.rehash(__n); }
1322 { _M_h.reserve(__n); }
1324 template<
typename _Key1,
typename _Tp1,
typename _Hash1,
typename _Pred1,
1331#if __cpp_deduction_guides >= 201606
1333 template<
typename _InputIterator,
1334 typename _Hash = hash<__iter_key_t<_InputIterator>>,
1335 typename _Pred = equal_to<__iter_key_t<_InputIterator>>,
1336 typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>,
1337 typename = _RequireInputIter<_InputIterator>,
1338 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1339 typename = _RequireNotAllocator<_Pred>,
1340 typename = _RequireAllocator<_Allocator>>
1341 unordered_map(_InputIterator, _InputIterator,
1342 typename unordered_map<int, int>::size_type = {},
1343 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1345 __iter_val_t<_InputIterator>,
1346 _Hash, _Pred, _Allocator>;
1348 template<
typename _Key,
typename _Tp,
typename _Hash = hash<_Key>,
1349 typename _Pred = equal_to<_Key>,
1350 typename _Allocator = allocator<pair<const _Key, _Tp>>,
1351 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1352 typename = _RequireNotAllocator<_Pred>,
1353 typename = _RequireAllocator<_Allocator>>
1356 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1359 template<
typename _InputIterator,
typename _Allocator,
1360 typename = _RequireInputIter<_InputIterator>,
1361 typename = _RequireAllocator<_Allocator>>
1365 __iter_val_t<_InputIterator>,
1370 template<
typename _InputIterator,
typename _Allocator,
1371 typename = _RequireInputIter<_InputIterator>,
1372 typename = _RequireAllocator<_Allocator>>
1375 __iter_val_t<_InputIterator>,
1380 template<
typename _InputIterator,
typename _Hash,
typename _Allocator,
1381 typename = _RequireInputIter<_InputIterator>,
1382 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1383 typename = _RequireAllocator<_Allocator>>
1388 __iter_val_t<_InputIterator>, _Hash,
1391 template<
typename _Key,
typename _Tp,
typename _Allocator,
1392 typename = _RequireAllocator<_Allocator>>
1398 template<
typename _Key,
typename _Tp,
typename _Allocator,
1399 typename = _RequireAllocator<_Allocator>>
1403 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Allocator,
1404 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1405 typename = _RequireAllocator<_Allocator>>
1411#if __glibcxx_containers_ranges
1415 __allocator_like _Allocator =
1418 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1420 __detail::__range_mapped_type<_Rg>,
1421 _Hash, _Pred, _Allocator>;
1424 __allocator_like _Allocator>
1428 __detail::__range_mapped_type<_Rg>,
1434 __allocator_like _Allocator>
1437 __detail::__range_mapped_type<_Rg>,
1443 __not_allocator_like _Hash,
1444 __allocator_like _Allocator>
1448 __detail::__range_mapped_type<_Rg>,
1479 template<
typename _Key,
typename _Tp,
1485 typedef __ummap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Hashtable;
1514#ifdef __glibcxx_node_extract
1515 using node_type =
typename _Hashtable::node_type;
1535 : _M_h(__n, __hf, __eql, __a)
1551 template<
typename _InputIterator>
1557 : _M_h(__first, __last, __n, __hf, __eql, __a)
1581 const allocator_type& __a)
1582 : _M_h(__ummap._M_h, __a)
1591 const allocator_type& __a)
1592 noexcept(
noexcept(_Hashtable(
std::move(__ummap._M_h), __a)) )
1593 : _M_h(
std::
move(__ummap._M_h), __a)
1612 : _M_h(__l, __n, __hf, __eql, __a)
1620 const allocator_type& __a)
1621 : unordered_multimap(__n, __hf,
key_equal(), __a)
1626 template<
typename _InputIterator>
1632 template<
typename _InputIterator>
1639 template<
typename _InputIterator>
1665#if __glibcxx_containers_ranges
1679 template<__detail::__container_compatible_range<value_type> _Rg>
1685 : _M_h(__n, __hf, __eql, __a)
1690 template<__detail::__container_compatible_range<value_type> _Rg>
1695 template<__detail::__container_compatible_range<value_type> _Rg>
1701 template<__detail::__container_compatible_range<value_type> _Rg>
1737 {
return _M_h.get_allocator(); }
1742 _GLIBCXX_NODISCARD
bool
1744 {
return _M_h.empty(); }
1749 {
return _M_h.size(); }
1754 {
return _M_h.max_size(); }
1764 {
return _M_h.begin(); }
1773 {
return _M_h.begin(); }
1777 {
return _M_h.begin(); }
1786 {
return _M_h.end(); }
1795 {
return _M_h.end(); }
1799 {
return _M_h.end(); }
1819 template<
typename... _Args>
1846 template<
typename... _Args>
1863 {
return _M_h.insert(__x); }
1869 template<
typename _Pair>
1870 __enable_if_t<is_constructible<value_type, _Pair&&>::value,
iterator>
1897 {
return _M_h.insert(__hint, __x); }
1903 {
return _M_h.insert(__hint,
std::move(__x)); }
1905 template<
typename _Pair>
1906 __enable_if_t<is_constructible<value_type, _Pair&&>::value,
iterator>
1920 template<
typename _InputIterator>
1922 insert(_InputIterator __first, _InputIterator __last)
1923 { _M_h.insert(__first, __last); }
1935 { _M_h.insert(__l); }
1937#if __glibcxx_containers_ranges
1944 template<__detail::__container_compatible_range<value_type> _Rg>
1946 insert_range(_Rg&& __rg)
1948 auto __first = ranges::begin(__rg);
1949 const auto __last = ranges::end(__rg);
1950 if (__first == __last)
1954 _M_h._M_rehash_insert(
size_type(ranges::distance(__rg)));
1956 _M_h._M_rehash_insert(1);
1958 for (; __first != __last; ++__first)
1959 _M_h.emplace(*__first);
1963#ifdef __glibcxx_node_extract
1966 extract(const_iterator __pos)
1968 __glibcxx_assert(__pos !=
end());
1969 return _M_h.extract(__pos);
1975 {
return _M_h.extract(__key); }
1977#ifdef __glibcxx_associative_heterogeneous_erasure
1978 template <__heterogeneous_hash_key<unordered_multimap> _Kt>
1980 extract(_Kt&& __key)
1981 {
return _M_h._M_extract_tr(__key); }
1987 {
return _M_h._M_reinsert_node_multi(
cend(),
std::move(__nh)); }
1992 {
return _M_h._M_reinsert_node_multi(__hint,
std::move(__nh)); }
2011 {
return _M_h.erase(__position); }
2016 {
return _M_h.erase(__position); }
2033 {
return _M_h.erase(__x); }
2035#ifdef __glibcxx_associative_heterogeneous_erasure
2036 template <__heterogeneous_hash_key<unordered_multimap> _Kt>
2039 {
return _M_h._M_erase_tr(__x); }
2061 {
return _M_h.erase(__first, __last); }
2085 noexcept(
noexcept(_M_h.swap(__x._M_h)) )
2086 { _M_h.swap(__x._M_h); }
2088#ifdef __glibcxx_node_extract
2089 template<
typename,
typename,
typename>
2090 friend class std::_Hash_merge_helper;
2092 template<
typename _H2,
typename _P2>
2096 if constexpr (is_same_v<_H2, _Hash> && is_same_v<_P2, _Pred>)
2101 = _Hash_merge_helper<unordered_multimap, _H2, _P2>;
2102 _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source));
2105 template<
typename _H2,
typename _P2>
2107 merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
2110 = _Hash_merge_helper<unordered_multimap, _H2, _P2>;
2111 _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source));
2114 template<
typename _H2,
typename _P2>
2116 merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>& __source)
2119 = _Hash_merge_helper<unordered_multimap, _H2, _P2>;
2120 _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source));
2123 template<
typename _H2,
typename _P2>
2125 merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
2126 { merge(__source); }
2135 {
return _M_h.hash_function(); }
2141 {
return _M_h.key_eq(); }
2159 {
return _M_h.find(__x); }
2161#ifdef __glibcxx_generic_unordered_lookup
2162 template<
typename _Kt>
2164 find(
const _Kt& __x) ->
decltype(_M_h._M_find_tr(__x))
2165 {
return _M_h._M_find_tr(__x); }
2170 {
return _M_h.find(__x); }
2172#ifdef __glibcxx_generic_unordered_lookup
2173 template<
typename _Kt>
2175 find(
const _Kt& __x)
const ->
decltype(_M_h._M_find_tr(__x))
2176 {
return _M_h._M_find_tr(__x); }
2188 {
return _M_h.count(__x); }
2190#ifdef __glibcxx_generic_unordered_lookup
2191 template<
typename _Kt>
2193 count(
const _Kt& __x)
const ->
decltype(_M_h._M_count_tr(__x))
2194 {
return _M_h._M_count_tr(__x); }
2198#if __cplusplus > 201703L
2207 {
return _M_h.find(__x) != _M_h.end(); }
2209 template<
typename _Kt>
2212 ->
decltype(_M_h._M_find_tr(__x),
void(),
true)
2213 {
return _M_h._M_find_tr(__x) != _M_h.end(); }
2226 {
return _M_h.equal_range(__x); }
2228#ifdef __glibcxx_generic_unordered_lookup
2229 template<
typename _Kt>
2232 ->
decltype(_M_h._M_equal_range_tr(__x))
2233 {
return _M_h._M_equal_range_tr(__x); }
2238 {
return _M_h.equal_range(__x); }
2240#ifdef __glibcxx_generic_unordered_lookup
2241 template<
typename _Kt>
2244 ->
decltype(_M_h._M_equal_range_tr(__x))
2245 {
return _M_h._M_equal_range_tr(__x); }
2254 {
return _M_h.bucket_count(); }
2259 {
return _M_h.max_bucket_count(); }
2268 {
return _M_h.bucket_size(__n); }
2277 bucket(
const key_type& __key)
const
2278 {
return _M_h.bucket(__key); }
2280#ifdef __glibcxx_associative_heterogeneous_insertion
2281 template <__heterogeneous_hash_key<unordered_multimap> _Kt>
2283 bucket(
const _Kt& __key)
const
2284 {
return _M_h._M_bucket_tr(__key); }
2296 {
return _M_h.begin(__n); }
2307 {
return _M_h.begin(__n); }
2311 {
return _M_h.cbegin(__n); }
2322 {
return _M_h.end(__n); }
2333 {
return _M_h.end(__n); }
2337 {
return _M_h.cend(__n); }
2345 {
return _M_h.load_factor(); }
2351 {
return _M_h.max_load_factor(); }
2359 { _M_h.max_load_factor(__z); }
2370 { _M_h.rehash(__n); }
2381 { _M_h.reserve(__n); }
2383 template<
typename _Key1,
typename _Tp1,
typename _Hash1,
typename _Pred1,
2387 _Hash1, _Pred1, _Alloc1>&,
2389 _Hash1, _Pred1, _Alloc1>&);
2392#if __cpp_deduction_guides >= 201606
2394 template<
typename _InputIterator,
2395 typename _Hash = hash<__iter_key_t<_InputIterator>>,
2396 typename _Pred = equal_to<__iter_key_t<_InputIterator>>,
2397 typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>,
2398 typename = _RequireInputIter<_InputIterator>,
2399 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2400 typename = _RequireNotAllocator<_Pred>,
2401 typename = _RequireAllocator<_Allocator>>
2402 unordered_multimap(_InputIterator, _InputIterator,
2403 unordered_multimap<int, int>::size_type = {},
2404 _Hash = _Hash(), _Pred = _Pred(),
2405 _Allocator = _Allocator())
2407 __iter_val_t<_InputIterator>, _Hash, _Pred,
2410 template<
typename _Key,
typename _Tp,
typename _Hash = hash<_Key>,
2411 typename _Pred = equal_to<_Key>,
2412 typename _Allocator = allocator<pair<const _Key, _Tp>>,
2413 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2414 typename = _RequireNotAllocator<_Pred>,
2415 typename = _RequireAllocator<_Allocator>>
2418 _Hash = _Hash(), _Pred = _Pred(),
2419 _Allocator = _Allocator())
2422 template<
typename _InputIterator,
typename _Allocator,
2423 typename = _RequireInputIter<_InputIterator>,
2424 typename = _RequireAllocator<_Allocator>>
2428 __iter_val_t<_InputIterator>,
2432 template<
typename _InputIterator,
typename _Allocator,
2433 typename = _RequireInputIter<_InputIterator>,
2434 typename = _RequireAllocator<_Allocator>>
2437 __iter_val_t<_InputIterator>,
2441 template<
typename _InputIterator,
typename _Hash,
typename _Allocator,
2442 typename = _RequireInputIter<_InputIterator>,
2443 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2444 typename = _RequireAllocator<_Allocator>>
2449 __iter_val_t<_InputIterator>, _Hash,
2452 template<
typename _Key,
typename _Tp,
typename _Allocator,
2453 typename = _RequireAllocator<_Allocator>>
2459 template<
typename _Key,
typename _Tp,
typename _Allocator,
2460 typename = _RequireAllocator<_Allocator>>
2464 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Allocator,
2465 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2466 typename = _RequireAllocator<_Allocator>>
2472#if __glibcxx_containers_ranges
2476 __allocator_like _Allocator =
2480 _Hash = _Hash(), _Pred = _Pred(),
2481 _Allocator = _Allocator())
2483 __detail::__range_mapped_type<_Rg>,
2484 _Hash, _Pred, _Allocator>;
2487 __allocator_like _Allocator>
2491 __detail::__range_mapped_type<_Rg>,
2497 __allocator_like _Allocator>
2500 __detail::__range_mapped_type<_Rg>,
2506 __not_allocator_like _Hash,
2507 __allocator_like _Allocator>
2512 __detail::__range_mapped_type<_Rg>,
2518 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2522 noexcept(
noexcept(__x.swap(__y)))
2525 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2529 noexcept(
noexcept(__x.swap(__y)))
2532 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2536 {
return __x._M_h._M_equal(__y._M_h); }
2538#if __cpp_impl_three_way_comparison < 201907L
2539 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2543 {
return !(__x == __y); }
2546 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2550 {
return __x._M_h._M_equal(__y._M_h); }
2552#if __cpp_impl_three_way_comparison < 201907L
2553 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2557 {
return !(__x == __y); }
2560_GLIBCXX_END_NAMESPACE_CONTAINER
2562#ifdef __glibcxx_node_extract
2564 template<
typename _Key,
typename _Val,
typename _Hash1,
typename _Eq1,
2565 typename _Alloc,
typename _Hash2,
typename _Eq2>
2566 struct _Hash_merge_helper<
2567 _GLIBCXX_STD_C::
unordered_map<_Key, _Val, _Hash1, _Eq1, _Alloc>,
2571 template<
typename... _Tp>
2572 using unordered_map = _GLIBCXX_STD_C::unordered_map<_Tp...>;
2573 template<
typename... _Tp>
2574 using unordered_multimap = _GLIBCXX_STD_C::unordered_multimap<_Tp...>;
2576 friend unordered_map<_Key, _Val, _Hash1, _Eq1, _Alloc>;
2579 _S_get_table(unordered_map<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
2580 {
return __map._M_h; }
2583 _S_get_table(unordered_multimap<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
2584 {
return __map._M_h; }
2588 template<
typename _Key,
typename _Val,
typename _Hash1,
typename _Eq1,
2589 typename _Alloc,
typename _Hash2,
typename _Eq2>
2590 struct _Hash_merge_helper<
2595 template<
typename... _Tp>
2596 using unordered_map = _GLIBCXX_STD_C::unordered_map<_Tp...>;
2597 template<
typename... _Tp>
2598 using unordered_multimap = _GLIBCXX_STD_C::unordered_multimap<_Tp...>;
2600 friend unordered_multimap<_Key, _Val, _Hash1, _Eq1, _Alloc>;
2603 _S_get_table(unordered_map<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
2604 {
return __map._M_h; }
2607 _S_get_table(unordered_multimap<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
2608 {
return __map._M_h; }
2612_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 (or references) 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.
size_type erase(_Kt &&__x)
Erases elements according to the provided 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.
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.
mapped_type & at(const _Kt &__k)
Access to unordered_map data.
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 mapped_type & at(const _Kt &__k) const
Access to unordered_map data.
const_iterator find(const key_type &__x) const
Tries to locate an element in an unordered_map.
unordered_map(unordered_map &&)=default
Move constructor.
mapped_type & operator[](_Kt &&__k)
Subscript ( [] ) access to unordered_map data.
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 erase(_Kt &&__x)
Erases elements according to the provided key.
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.