30#ifndef _UNORDERED_MAP_H
31#define _UNORDERED_MAP_H
38namespace std _GLIBCXX_VISIBILITY(default)
40_GLIBCXX_BEGIN_NAMESPACE_VERSION
41_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
47 template<
typename _Key,
53 using __umap_hashtable = _Hashtable<_Key, std::pair<const _Key, _Tp>,
54 _Alloc, __detail::_Select1st,
56 __detail::_Mod_range_hashing,
57 __detail::_Default_ranged_hash,
58 __detail::_Prime_rehash_policy, _Tr>;
64 template<
typename _Key,
70 using __ummap_hashtable = _Hashtable<_Key, std::pair<const _Key, _Tp>,
71 _Alloc, __detail::_Select1st,
73 __detail::_Mod_range_hashing,
74 __detail::_Default_ranged_hash,
75 __detail::_Prime_rehash_policy, _Tr>;
77 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
105 template<
typename _Key,
typename _Tp,
111 typedef __umap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Hashtable;
121 typedef typename _Hashtable::hasher
hasher;
140#if __cplusplus > 201402L
141 using node_type =
typename _Hashtable::node_type;
142 using insert_return_type =
typename _Hashtable::insert_return_type;
162 : _M_h(__n, __hf, __eql, __a)
178 template<
typename _InputIterator>
184 : _M_h(__first, __last, __n, __hf, __eql, __a)
209 : _M_h(__umap._M_h, __a)
219 noexcept(
noexcept(_Hashtable(
std::move(__umap._M_h), __a)) )
239 : _M_h(__l, __n, __hf, __eql, __a)
251 template<
typename _InputIterator>
258 template<
typename _InputIterator>
306 {
return _M_h.get_allocator(); }
311 _GLIBCXX_NODISCARD
bool
313 {
return _M_h.empty(); }
318 {
return _M_h.size(); }
323 {
return _M_h.max_size(); }
333 {
return _M_h.begin(); }
342 {
return _M_h.begin(); }
346 {
return _M_h.begin(); }
355 {
return _M_h.end(); }
364 {
return _M_h.end(); }
368 {
return _M_h.end(); }
393 template<
typename... _Args>
396 {
return _M_h.emplace(std::forward<_Args>(__args)...); }
424 template<
typename... _Args>
427 {
return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
429#if __cplusplus > 201402L
434 __glibcxx_assert(__pos !=
end());
435 return _M_h.extract(__pos);
441 {
return _M_h.extract(__key); }
446 {
return _M_h._M_reinsert_node(
std::move(__nh)); }
451 {
return _M_h._M_reinsert_node(
std::move(__nh)).position; }
454#ifdef __glibcxx_unordered_map_try_emplace
477 template <
typename... _Args>
481 return _M_h.try_emplace(
cend(), __k, std::forward<_Args>(__args)...);
485 template <
typename... _Args>
490 std::forward<_Args>(__args)...);
521 template <
typename... _Args>
526 return _M_h.try_emplace(__hint, __k,
527 std::forward<_Args>(__args)...).first;
531 template <
typename... _Args>
535 return _M_h.try_emplace(__hint,
std::move(__k),
536 std::forward<_Args>(__args)...).first;
560 {
return _M_h.insert(__x); }
568 template<
typename _Pair>
569 __enable_if_t<is_constructible<value_type, _Pair&&>::value,
572 {
return _M_h.emplace(std::forward<_Pair>(__x)); }
599 {
return _M_h.insert(__hint, __x); }
605 {
return _M_h.insert(__hint,
std::move(__x)); }
607 template<
typename _Pair>
608 __enable_if_t<is_constructible<value_type, _Pair&&>::value,
iterator>
610 {
return _M_h.emplace_hint(__hint, std::forward<_Pair>(__x)); }
622 template<
typename _InputIterator>
624 insert(_InputIterator __first, _InputIterator __last)
625 { _M_h.insert(__first, __last); }
636 { _M_h.insert(__l); }
639#if __cplusplus > 201402L
660 template <
typename _Obj>
664 auto __ret = _M_h.try_emplace(
cend(), __k,
665 std::forward<_Obj>(__obj));
667 __ret.first->second = std::forward<_Obj>(__obj);
672 template <
typename _Obj>
677 std::forward<_Obj>(__obj));
679 __ret.first->second = std::forward<_Obj>(__obj);
709 template <
typename _Obj>
714 auto __ret = _M_h.try_emplace(__hint, __k, std::forward<_Obj>(__obj));
716 __ret.first->second = std::forward<_Obj>(__obj);
721 template <
typename _Obj>
725 auto __ret = _M_h.try_emplace(__hint,
std::move(__k),
726 std::forward<_Obj>(__obj));
728 __ret.first->second = std::forward<_Obj>(__obj);
749 {
return _M_h.erase(__position); }
754 {
return _M_h.erase(__position); }
771 {
return _M_h.erase(__x); }
789 {
return _M_h.erase(__first, __last); }
813 noexcept(
noexcept(_M_h.swap(__x._M_h)) )
814 { _M_h.swap(__x._M_h); }
816#if __cplusplus > 201402L
817 template<
typename,
typename,
typename>
818 friend class std::_Hash_merge_helper;
820 template<
typename _H2,
typename _P2>
824 using _Merge_helper = _Hash_merge_helper<unordered_map, _H2, _P2>;
825 _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source));
828 template<
typename _H2,
typename _P2>
830 merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
833 template<
typename _H2,
typename _P2>
835 merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>& __source)
837 using _Merge_helper = _Hash_merge_helper<unordered_map, _H2, _P2>;
838 _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source));
841 template<
typename _H2,
typename _P2>
843 merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
853 {
return _M_h.hash_function(); }
859 {
return _M_h.key_eq(); }
877 {
return _M_h.find(__x); }
879#if __cplusplus > 201703L
880 template<
typename _Kt>
882 find(
const _Kt& __x) ->
decltype(_M_h._M_find_tr(__x))
883 {
return _M_h._M_find_tr(__x); }
888 {
return _M_h.find(__x); }
890#if __cplusplus > 201703L
891 template<
typename _Kt>
893 find(
const _Kt& __x)
const ->
decltype(_M_h._M_find_tr(__x))
894 {
return _M_h._M_find_tr(__x); }
910 {
return _M_h.count(__x); }
912#if __cplusplus > 201703L
913 template<
typename _Kt>
915 count(
const _Kt& __x)
const ->
decltype(_M_h._M_count_tr(__x))
916 {
return _M_h._M_count_tr(__x); }
920#if __cplusplus > 201703L
929 {
return _M_h.find(__x) != _M_h.end(); }
931 template<
typename _Kt>
934 ->
decltype(_M_h._M_find_tr(__x), void(),
true)
935 {
return _M_h._M_find_tr(__x) != _M_h.end(); }
950 {
return _M_h.equal_range(__x); }
952#if __cplusplus > 201703L
953 template<
typename _Kt>
956 ->
decltype(_M_h._M_equal_range_tr(__x))
957 {
return _M_h._M_equal_range_tr(__x); }
962 {
return _M_h.equal_range(__x); }
964#if __cplusplus > 201703L
965 template<
typename _Kt>
968 ->
decltype(_M_h._M_equal_range_tr(__x))
969 {
return _M_h._M_equal_range_tr(__x); }
988 {
return _M_h[__k]; }
1005 {
return _M_h.at(__k); }
1009 {
return _M_h.at(__k); }
1017 {
return _M_h.bucket_count(); }
1022 {
return _M_h.max_bucket_count(); }
1031 {
return _M_h.bucket_size(__n); }
1039 bucket(
const key_type& __key)
const
1040 {
return _M_h.bucket(__key); }
1050 {
return _M_h.begin(__n); }
1061 {
return _M_h.begin(__n); }
1065 {
return _M_h.cbegin(__n); }
1076 {
return _M_h.end(__n); }
1087 {
return _M_h.end(__n); }
1091 {
return _M_h.cend(__n); }
1099 {
return _M_h.load_factor(); }
1105 {
return _M_h.max_load_factor(); }
1113 { _M_h.max_load_factor(__z); }
1124 { _M_h.rehash(__n); }
1135 { _M_h.reserve(__n); }
1137 template<
typename _Key1,
typename _Tp1,
typename _Hash1,
typename _Pred1,
1144#if __cpp_deduction_guides >= 201606
1146 template<
typename _InputIterator,
1147 typename _Hash = hash<__iter_key_t<_InputIterator>>,
1148 typename _Pred = equal_to<__iter_key_t<_InputIterator>>,
1149 typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>,
1150 typename = _RequireInputIter<_InputIterator>,
1151 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1152 typename = _RequireNotAllocator<_Pred>,
1153 typename = _RequireAllocator<_Allocator>>
1154 unordered_map(_InputIterator, _InputIterator,
1156 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1157 -> unordered_map<__iter_key_t<_InputIterator>,
1158 __iter_val_t<_InputIterator>,
1159 _Hash, _Pred, _Allocator>;
1161 template<
typename _Key,
typename _Tp,
typename _Hash = hash<_Key>,
1162 typename _Pred = equal_to<_Key>,
1163 typename _Allocator = allocator<pair<const _Key, _Tp>>,
1164 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1165 typename = _RequireNotAllocator<_Pred>,
1166 typename = _RequireAllocator<_Allocator>>
1167 unordered_map(initializer_list<pair<_Key, _Tp>>,
1169 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1170 -> unordered_map<_Key, _Tp, _Hash, _Pred, _Allocator>;
1172 template<
typename _InputIterator,
typename _Allocator,
1173 typename = _RequireInputIter<_InputIterator>,
1174 typename = _RequireAllocator<_Allocator>>
1175 unordered_map(_InputIterator, _InputIterator,
1177 -> unordered_map<__iter_key_t<_InputIterator>,
1178 __iter_val_t<_InputIterator>,
1179 hash<__iter_key_t<_InputIterator>>,
1180 equal_to<__iter_key_t<_InputIterator>>,
1183 template<
typename _InputIterator,
typename _Allocator,
1184 typename = _RequireInputIter<_InputIterator>,
1185 typename = _RequireAllocator<_Allocator>>
1186 unordered_map(_InputIterator, _InputIterator, _Allocator)
1187 -> unordered_map<__iter_key_t<_InputIterator>,
1188 __iter_val_t<_InputIterator>,
1189 hash<__iter_key_t<_InputIterator>>,
1190 equal_to<__iter_key_t<_InputIterator>>,
1193 template<
typename _InputIterator,
typename _Hash,
typename _Allocator,
1194 typename = _RequireInputIter<_InputIterator>,
1195 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1196 typename = _RequireAllocator<_Allocator>>
1197 unordered_map(_InputIterator, _InputIterator,
1200 -> unordered_map<__iter_key_t<_InputIterator>,
1201 __iter_val_t<_InputIterator>, _Hash,
1202 equal_to<__iter_key_t<_InputIterator>>, _Allocator>;
1204 template<
typename _Key,
typename _Tp,
typename _Allocator,
1205 typename = _RequireAllocator<_Allocator>>
1206 unordered_map(initializer_list<pair<_Key, _Tp>>,
1209 -> unordered_map<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>;
1211 template<
typename _Key,
typename _Tp,
typename _Allocator,
1212 typename = _RequireAllocator<_Allocator>>
1213 unordered_map(initializer_list<pair<_Key, _Tp>>, _Allocator)
1214 -> unordered_map<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>;
1216 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Allocator,
1217 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1218 typename = _RequireAllocator<_Allocator>>
1219 unordered_map(initializer_list<pair<_Key, _Tp>>,
1222 -> unordered_map<_Key, _Tp, _Hash, equal_to<_Key>, _Allocator>;
1251 template<
typename _Key,
typename _Tp,
1252 typename _Hash = hash<_Key>,
1253 typename _Pred = equal_to<_Key>,
1254 typename _Alloc = allocator<std::pair<const _Key, _Tp>>>
1257 typedef __ummap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Hashtable;
1286#if __cplusplus > 201402L
1287 using node_type =
typename _Hashtable::node_type;
1307 : _M_h(__n, __hf, __eql, __a)
1323 template<
typename _InputIterator>
1329 : _M_h(__first, __last, __n, __hf, __eql, __a)
1354 : _M_h(__ummap._M_h, __a)
1364 noexcept(
noexcept(_Hashtable(
std::move(__ummap._M_h), __a)) )
1384 : _M_h(__l, __n, __hf, __eql, __a)
1396 template<
typename _InputIterator>
1403 template<
typename _InputIterator>
1451 {
return _M_h.get_allocator(); }
1456 _GLIBCXX_NODISCARD
bool
1458 {
return _M_h.empty(); }
1463 {
return _M_h.size(); }
1468 {
return _M_h.max_size(); }
1478 {
return _M_h.begin(); }
1487 {
return _M_h.begin(); }
1491 {
return _M_h.begin(); }
1500 {
return _M_h.end(); }
1509 {
return _M_h.end(); }
1513 {
return _M_h.end(); }
1533 template<
typename... _Args>
1536 {
return _M_h.emplace(std::forward<_Args>(__args)...); }
1560 template<
typename... _Args>
1563 {
return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
1577 {
return _M_h.insert(__x); }
1583 template<
typename _Pair>
1584 __enable_if_t<is_constructible<value_type, _Pair&&>::value,
iterator>
1586 {
return _M_h.emplace(std::forward<_Pair>(__x)); }
1611 {
return _M_h.insert(__hint, __x); }
1617 {
return _M_h.insert(__hint,
std::move(__x)); }
1619 template<
typename _Pair>
1620 __enable_if_t<is_constructible<value_type, _Pair&&>::value,
iterator>
1622 {
return _M_h.emplace_hint(__hint, std::forward<_Pair>(__x)); }
1634 template<
typename _InputIterator>
1636 insert(_InputIterator __first, _InputIterator __last)
1637 { _M_h.insert(__first, __last); }
1649 { _M_h.insert(__l); }
1651#if __cplusplus > 201402L
1656 __glibcxx_assert(__pos !=
end());
1657 return _M_h.extract(__pos);
1663 {
return _M_h.extract(__key); }
1668 {
return _M_h._M_reinsert_node_multi(
cend(),
std::move(__nh)); }
1673 {
return _M_h._M_reinsert_node_multi(__hint,
std::move(__nh)); }
1692 {
return _M_h.erase(__position); }
1697 {
return _M_h.erase(__position); }
1713 {
return _M_h.erase(__x); }
1732 {
return _M_h.erase(__first, __last); }
1756 noexcept(
noexcept(_M_h.swap(__x._M_h)) )
1757 { _M_h.swap(__x._M_h); }
1759#if __cplusplus > 201402L
1760 template<
typename,
typename,
typename>
1761 friend class std::_Hash_merge_helper;
1763 template<
typename _H2,
typename _P2>
1768 = _Hash_merge_helper<unordered_multimap, _H2, _P2>;
1769 _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source));
1772 template<
typename _H2,
typename _P2>
1774 merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
1775 { merge(__source); }
1777 template<
typename _H2,
typename _P2>
1779 merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>& __source)
1782 = _Hash_merge_helper<unordered_multimap, _H2, _P2>;
1783 _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source));
1786 template<
typename _H2,
typename _P2>
1788 merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
1789 { merge(__source); }
1798 {
return _M_h.hash_function(); }
1804 {
return _M_h.key_eq(); }
1822 {
return _M_h.find(__x); }
1824#if __cplusplus > 201703L
1825 template<
typename _Kt>
1827 find(
const _Kt& __x) ->
decltype(_M_h._M_find_tr(__x))
1828 {
return _M_h._M_find_tr(__x); }
1833 {
return _M_h.find(__x); }
1835#if __cplusplus > 201703L
1836 template<
typename _Kt>
1838 find(
const _Kt& __x)
const ->
decltype(_M_h._M_find_tr(__x))
1839 {
return _M_h._M_find_tr(__x); }
1851 {
return _M_h.count(__x); }
1853#if __cplusplus > 201703L
1854 template<
typename _Kt>
1856 count(
const _Kt& __x)
const ->
decltype(_M_h._M_count_tr(__x))
1857 {
return _M_h._M_count_tr(__x); }
1861#if __cplusplus > 201703L
1870 {
return _M_h.find(__x) != _M_h.end(); }
1872 template<
typename _Kt>
1875 ->
decltype(_M_h._M_find_tr(__x), void(),
true)
1876 {
return _M_h._M_find_tr(__x) != _M_h.end(); }
1889 {
return _M_h.equal_range(__x); }
1891#if __cplusplus > 201703L
1892 template<
typename _Kt>
1895 ->
decltype(_M_h._M_equal_range_tr(__x))
1896 {
return _M_h._M_equal_range_tr(__x); }
1901 {
return _M_h.equal_range(__x); }
1903#if __cplusplus > 201703L
1904 template<
typename _Kt>
1907 ->
decltype(_M_h._M_equal_range_tr(__x))
1908 {
return _M_h._M_equal_range_tr(__x); }
1917 {
return _M_h.bucket_count(); }
1922 {
return _M_h.max_bucket_count(); }
1931 {
return _M_h.bucket_size(__n); }
1939 bucket(
const key_type& __key)
const
1940 {
return _M_h.bucket(__key); }
1950 {
return _M_h.begin(__n); }
1961 {
return _M_h.begin(__n); }
1965 {
return _M_h.cbegin(__n); }
1976 {
return _M_h.end(__n); }
1987 {
return _M_h.end(__n); }
1991 {
return _M_h.cend(__n); }
1999 {
return _M_h.load_factor(); }
2005 {
return _M_h.max_load_factor(); }
2013 { _M_h.max_load_factor(__z); }
2024 { _M_h.rehash(__n); }
2035 { _M_h.reserve(__n); }
2037 template<
typename _Key1,
typename _Tp1,
typename _Hash1,
typename _Pred1,
2041 _Hash1, _Pred1, _Alloc1>&,
2043 _Hash1, _Pred1, _Alloc1>&);
2046#if __cpp_deduction_guides >= 201606
2048 template<
typename _InputIterator,
2049 typename _Hash = hash<__iter_key_t<_InputIterator>>,
2050 typename _Pred = equal_to<__iter_key_t<_InputIterator>>,
2051 typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>,
2052 typename = _RequireInputIter<_InputIterator>,
2053 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2054 typename = _RequireNotAllocator<_Pred>,
2055 typename = _RequireAllocator<_Allocator>>
2056 unordered_multimap(_InputIterator, _InputIterator,
2058 _Hash = _Hash(), _Pred = _Pred(),
2059 _Allocator = _Allocator())
2060 -> unordered_multimap<__iter_key_t<_InputIterator>,
2061 __iter_val_t<_InputIterator>, _Hash, _Pred,
2064 template<
typename _Key,
typename _Tp,
typename _Hash = hash<_Key>,
2065 typename _Pred = equal_to<_Key>,
2066 typename _Allocator = allocator<pair<const _Key, _Tp>>,
2067 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2068 typename = _RequireNotAllocator<_Pred>,
2069 typename = _RequireAllocator<_Allocator>>
2070 unordered_multimap(initializer_list<pair<_Key, _Tp>>,
2072 _Hash = _Hash(), _Pred = _Pred(),
2073 _Allocator = _Allocator())
2074 -> unordered_multimap<_Key, _Tp, _Hash, _Pred, _Allocator>;
2076 template<
typename _InputIterator,
typename _Allocator,
2077 typename = _RequireInputIter<_InputIterator>,
2078 typename = _RequireAllocator<_Allocator>>
2079 unordered_multimap(_InputIterator, _InputIterator,
2081 -> unordered_multimap<__iter_key_t<_InputIterator>,
2082 __iter_val_t<_InputIterator>,
2083 hash<__iter_key_t<_InputIterator>>,
2084 equal_to<__iter_key_t<_InputIterator>>, _Allocator>;
2086 template<
typename _InputIterator,
typename _Allocator,
2087 typename = _RequireInputIter<_InputIterator>,
2088 typename = _RequireAllocator<_Allocator>>
2089 unordered_multimap(_InputIterator, _InputIterator, _Allocator)
2090 -> unordered_multimap<__iter_key_t<_InputIterator>,
2091 __iter_val_t<_InputIterator>,
2092 hash<__iter_key_t<_InputIterator>>,
2093 equal_to<__iter_key_t<_InputIterator>>, _Allocator>;
2095 template<
typename _InputIterator,
typename _Hash,
typename _Allocator,
2096 typename = _RequireInputIter<_InputIterator>,
2097 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2098 typename = _RequireAllocator<_Allocator>>
2099 unordered_multimap(_InputIterator, _InputIterator,
2102 -> unordered_multimap<__iter_key_t<_InputIterator>,
2103 __iter_val_t<_InputIterator>, _Hash,
2104 equal_to<__iter_key_t<_InputIterator>>, _Allocator>;
2106 template<
typename _Key,
typename _Tp,
typename _Allocator,
2107 typename = _RequireAllocator<_Allocator>>
2108 unordered_multimap(initializer_list<pair<_Key, _Tp>>,
2111 -> unordered_multimap<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>;
2113 template<
typename _Key,
typename _Tp,
typename _Allocator,
2114 typename = _RequireAllocator<_Allocator>>
2115 unordered_multimap(initializer_list<pair<_Key, _Tp>>, _Allocator)
2116 -> unordered_multimap<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>;
2118 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Allocator,
2119 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2120 typename = _RequireAllocator<_Allocator>>
2121 unordered_multimap(initializer_list<pair<_Key, _Tp>>,
2124 -> unordered_multimap<_Key, _Tp, _Hash, equal_to<_Key>, _Allocator>;
2128 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2130 swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2131 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2132 noexcept(
noexcept(__x.swap(__y)))
2135 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2137 swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2138 unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2139 noexcept(
noexcept(__x.swap(__y)))
2142 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2144 operator==(
const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2145 const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2146 {
return __x._M_h._M_equal(__y._M_h); }
2148#if __cpp_impl_three_way_comparison < 201907L
2149 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2151 operator!=(
const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2152 const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2153 {
return !(__x == __y); }
2156 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2158 operator==(
const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2159 const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2160 {
return __x._M_h._M_equal(__y._M_h); }
2162#if __cpp_impl_three_way_comparison < 201907L
2163 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
2165 operator!=(
const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2166 const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2167 {
return !(__x == __y); }
2170_GLIBCXX_END_NAMESPACE_CONTAINER
2172#if __cplusplus > 201402L
2174 template<
typename _Key,
typename _Val,
typename _Hash1,
typename _Eq1,
2175 typename _Alloc,
typename _Hash2,
typename _Eq2>
2176 struct _Hash_merge_helper<
2177 _GLIBCXX_STD_C::unordered_map<_Key, _Val, _Hash1, _Eq1, _Alloc>,
2181 template<
typename... _Tp>
2182 using unordered_map = _GLIBCXX_STD_C::unordered_map<_Tp...>;
2183 template<
typename... _Tp>
2184 using unordered_multimap = _GLIBCXX_STD_C::unordered_multimap<_Tp...>;
2186 friend unordered_map<_Key, _Val, _Hash1, _Eq1, _Alloc>;
2189 _S_get_table(unordered_map<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
2190 {
return __map._M_h; }
2193 _S_get_table(unordered_multimap<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
2194 {
return __map._M_h; }
2198 template<
typename _Key,
typename _Val,
typename _Hash1,
typename _Eq1,
2199 typename _Alloc,
typename _Hash2,
typename _Eq2>
2200 struct _Hash_merge_helper<
2201 _GLIBCXX_STD_C::unordered_multimap<_Key, _Val, _Hash1, _Eq1, _Alloc>,
2205 template<
typename... _Tp>
2206 using unordered_map = _GLIBCXX_STD_C::unordered_map<_Tp...>;
2207 template<
typename... _Tp>
2208 using unordered_multimap = _GLIBCXX_STD_C::unordered_multimap<_Tp...>;
2210 friend unordered_multimap<_Key, _Val, _Hash1, _Eq1, _Alloc>;
2213 _S_get_table(unordered_map<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
2214 {
return __map._M_h; }
2217 _S_get_table(unordered_multimap<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
2218 {
return __map._M_h; }
2222_GLIBCXX_END_NAMESPACE_VERSION
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
ISO C++ entities toplevel namespace is std.
__detail::_Hashtable_traits< _Cache, false, false > __ummap_traits
Base types for unordered_multimap.
__detail::_Hashtable_traits< _Cache, false, true > __umap_traits
Base types for unordered_map.
Primary class template hash.
The standard allocator, as per C++03 [20.4.1].
One of the comparison functors.
Struct holding two objects of arbitrary type.
A standard container composed of equivalent keys (possibly containing multiple of each key value) tha...
float load_factor() const noexcept
Returns the average number of elements per bucket.
_Hashtable::reference reference
Iterator-related typedefs.
iterator erase(iterator __position)
Erases an element from an unordered_multimap.
const_iterator end() const noexcept
size_type erase(const key_type &__x)
Erases elements according to the provided key.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
size_type bucket_count() const noexcept
Returns the number of buckets of the unordered_multimap.
_Hashtable::iterator iterator
Iterator-related typedefs.
size_type max_bucket_count() const noexcept
Returns the maximum number of buckets of the unordered_multimap.
iterator begin() noexcept
const_iterator begin() const noexcept
hasher hash_function() const
Returns the hash functor object with which the unordered_multimap was constructed.
iterator insert(const_iterator __hint, node_type &&__nh)
Re-insert an extracted node.
__enable_if_t< is_constructible< value_type, _Pair && >::value, iterator > insert(const_iterator __hint, _Pair &&__x)
Inserts a std::pair into the unordered_multimap.
unordered_multimap & operator=(const unordered_multimap &)=default
Copy assignment operator.
key_equal key_eq() const
Returns the key comparison object with which the unordered_multimap was constructed.
size_type count(const key_type &__x) const
Finds the number of elements.
const_iterator find(const key_type &__x) const
Tries to locate an element in an unordered_multimap.
_Hashtable::mapped_type mapped_type
Public typedefs.
auto find(const _Kt &__x) -> decltype(_M_h._M_find_tr(__x))
Tries to locate an element in an unordered_multimap.
local_iterator end(size_type __n)
Returns a read/write iterator pointing to one past the last bucket elements.
void insert(_InputIterator __first, _InputIterator __last)
A template function that attempts to insert a range of elements.
unordered_multimap & operator=(initializer_list< value_type > __l)
Unordered_multimap list assignment operator.
unordered_multimap(size_type __n, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type())
Default constructor creates no elements.
_Hashtable::value_type value_type
Public typedefs.
iterator emplace(_Args &&... __args)
Attempts to build and insert a std::pair into the unordered_multimap.
node_type extract(const key_type &__key)
Extract a node.
bool contains(const key_type &__x) const
Finds whether an element with the given key exists.
_Hashtable::const_reference const_reference
Iterator-related typedefs.
iterator insert(node_type &&__nh)
Re-insert an extracted node.
iterator erase(const_iterator __position)
Erases an element from an unordered_multimap.
local_iterator begin(size_type __n)
Returns a read/write iterator pointing to the first bucket element.
float max_load_factor() const noexcept
Returns a positive number that the unordered_multimap tries to keep the load factor less than or equa...
unordered_multimap()=default
Default constructor.
iterator insert(value_type &&__x)
Inserts a std::pair into the unordered_multimap.
iterator insert(const value_type &__x)
Inserts a std::pair into the unordered_multimap.
unordered_multimap & operator=(unordered_multimap &&)=default
Move assignment operator.
_Hashtable::hasher hasher
Public typedefs.
_Hashtable::local_iterator local_iterator
Iterator-related typedefs.
void reserve(size_type __n)
Prepare the unordered_multimap for a specified number of elements.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n=0, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type())
Builds an unordered_multimap from a range.
iterator find(const key_type &__x)
Tries to locate an element in an unordered_multimap.
unordered_multimap(initializer_list< value_type > __l, size_type __n=0, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type())
Builds an unordered_multimap from an initializer_list.
auto count(const _Kt &__x) const -> decltype(_M_h._M_count_tr(__x))
Finds the number of elements.
iterator erase(const_iterator __first, const_iterator __last)
Erases a [__first,__last) range of elements from an unordered_multimap.
const_local_iterator end(size_type __n) const
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
_Hashtable::pointer pointer
Iterator-related typedefs.
_Hashtable::allocator_type allocator_type
Public typedefs.
const_local_iterator begin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
auto find(const _Kt &__x) const -> decltype(_M_h._M_find_tr(__x))
Tries to locate an element in an unordered_multimap.
_Hashtable::const_local_iterator const_local_iterator
Iterator-related typedefs.
unordered_multimap(unordered_multimap &&)=default
Move constructor.
unordered_multimap(const allocator_type &__a)
Creates an unordered_multimap with no elements.
_Hashtable::difference_type difference_type
Iterator-related typedefs.
_Hashtable::size_type size_type
Iterator-related typedefs.
_Hashtable::const_pointer const_pointer
Iterator-related typedefs.
__enable_if_t< is_constructible< value_type, _Pair && >::value, iterator > insert(_Pair &&__x)
Inserts a std::pair into the unordered_multimap.
auto contains(const _Kt &__x) const -> decltype(_M_h._M_find_tr(__x), void(), true)
Finds whether an element with the given key exists.
void swap(unordered_multimap &__x) noexcept(noexcept(_M_h.swap(__x._M_h)))
Swaps data with another unordered_multimap.
void rehash(size_type __n)
May rehash the unordered_multimap.
_Hashtable::const_iterator const_iterator
Iterator-related typedefs.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the unordered_multimap.
const_iterator cend() const noexcept
size_type max_size() const noexcept
Returns the maximum size of the unordered_multimap.
const_local_iterator cbegin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
bool empty() const noexcept
Returns true if the unordered_multimap is empty.
const_iterator cbegin() const noexcept
_Hashtable::key_type key_type
Public typedefs.
node_type extract(const_iterator __pos)
Extract a node.
const_local_iterator cend(size_type __n) const
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
iterator insert(const_iterator __hint, const value_type &__x)
Inserts a std::pair into the unordered_multimap.
size_type size() const noexcept
Returns the size of the unordered_multimap.
unordered_multimap(const unordered_multimap &)=default
Copy constructor.
iterator emplace_hint(const_iterator __pos, _Args &&... __args)
Attempts to build and insert a std::pair into the unordered_multimap.
iterator insert(const_iterator __hint, value_type &&__x)
Inserts a std::pair into the unordered_multimap.
auto equal_range(const _Kt &__x) -> decltype(_M_h._M_equal_range_tr(__x))
Finds a subsequence matching given key.
_Hashtable::key_equal key_equal
Public typedefs.
allocator_type get_allocator() const noexcept
Returns the allocator object used by the unordered_multimap.
void max_load_factor(float __z)
Change the unordered_multimap maximum load factor.
auto equal_range(const _Kt &__x) const -> decltype(_M_h._M_equal_range_tr(__x))
Finds a subsequence matching given key.
A standard container composed of unique keys (containing at most one of each key value) that associat...
iterator insert(const_iterator __hint, value_type &&__x)
Attempts to insert a std::pair into the unordered_map.
_Hashtable::iterator iterator
Iterator-related typedefs.
void max_load_factor(float __z)
Change the unordered_map maximum load factor.
const mapped_type & at(const key_type &__k) const
Access to unordered_map data.
bool contains(const key_type &__x) const
Finds whether an element with the given key exists.
node_type extract(const key_type &__key)
Extract a node.
void insert(_InputIterator __first, _InputIterator __last)
A template function that attempts to insert a range of elements.
allocator_type get_allocator() const noexcept
Returns the allocator object used by the unordered_map.
auto find(const _Kt &__x) -> decltype(_M_h._M_find_tr(__x))
Tries to locate an element in an unordered_map.
unordered_map & operator=(initializer_list< value_type > __l)
Unordered_map list assignment operator.
_Hashtable::const_pointer const_pointer
Iterator-related typedefs.
auto find(const _Kt &__x) const -> decltype(_M_h._M_find_tr(__x))
Tries to locate an element in an unordered_map.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the unordered_map.
__enable_if_t< is_constructible< value_type, _Pair && >::value, iterator > insert(const_iterator __hint, _Pair &&__x)
Attempts to insert a std::pair into the unordered_map.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
mapped_type & at(const key_type &__k)
Access to unordered_map data.
iterator erase(const_iterator __first, const_iterator __last)
Erases a [__first,__last) range of elements from an unordered_map.
iterator try_emplace(const_iterator __hint, const key_type &__k, _Args &&... __args)
Attempts to build and insert a std::pair into the unordered_map.
node_type extract(const_iterator __pos)
Extract a node.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert a std::pair into the unordered_map.
void reserve(size_type __n)
Prepare the unordered_map for a specified number of elements.
const_local_iterator cbegin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
iterator insert(const_iterator, node_type &&__nh)
Re-insert an extracted node.
_Hashtable::reference reference
Iterator-related typedefs.
iterator insert(const_iterator __hint, const value_type &__x)
Attempts to insert a std::pair into the unordered_map.
_Hashtable::allocator_type allocator_type
Public typedefs.
unordered_map(const unordered_map &)=default
Copy constructor.
size_type count(const key_type &__x) const
Finds the number of elements.
bool empty() const noexcept
Returns true if the unordered_map is empty.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
const_iterator find(const key_type &__x) const
Tries to locate an element in an unordered_map.
unordered_map(unordered_map &&)=default
Move constructor.
const_local_iterator end(size_type __n) const
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
auto equal_range(const _Kt &__x) -> decltype(_M_h._M_equal_range_tr(__x))
Finds a subsequence matching given key.
auto contains(const _Kt &__x) const -> decltype(_M_h._M_find_tr(__x), void(), true)
Finds whether an element with the given key exists.
size_type max_size() const noexcept
Returns the maximum size of the unordered_map.
const_iterator end() const noexcept
unordered_map()=default
Default constructor.
_Hashtable::mapped_type mapped_type
Public typedefs.
unordered_map & operator=(unordered_map &&)=default
Move assignment operator.
const_local_iterator begin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
unordered_map(size_type __n, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type())
Default constructor creates no elements.
std::pair< iterator, bool > emplace(_Args &&... __args)
Attempts to build and insert a std::pair into the unordered_map.
const_local_iterator cend(size_type __n) const
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
size_type size() const noexcept
Returns the size of the unordered_map.
__enable_if_t< is_constructible< value_type, _Pair && >::value, pair< iterator, bool > > insert(_Pair &&__x)
Attempts to insert a std::pair into the unordered_map.
mapped_type & operator[](key_type &&__k)
Subscript ( [] ) access to unordered_map data.
std::pair< iterator, bool > insert(value_type &&__x)
Attempts to insert a std::pair into the unordered_map.
_Hashtable::hasher hasher
Public typedefs.
pair< iterator, bool > insert_or_assign(const key_type &__k, _Obj &&__obj)
Attempts to insert a std::pair into the unordered_map.
unordered_map(_InputIterator __first, _InputIterator __last, size_type __n=0, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type())
Builds an unordered_map from a range.
mapped_type & operator[](const key_type &__k)
Subscript ( [] ) access to unordered_map data.
pair< iterator, bool > try_emplace(const key_type &__k, _Args &&... __args)
Attempts to build and insert a std::pair into the unordered_map.
const_iterator begin() const noexcept
key_equal key_eq() const
Returns the key comparison object with which the unordered_map was constructed.
_Hashtable::const_reference const_reference
Iterator-related typedefs.
_Hashtable::key_equal key_equal
Public typedefs.
_Hashtable::local_iterator local_iterator
Iterator-related typedefs.
iterator erase(iterator __position)
Erases an element from an unordered_map.
const_iterator cend() const noexcept
local_iterator end(size_type __n)
Returns a read/write iterator pointing to one past the last bucket elements.
_Hashtable::pointer pointer
Iterator-related typedefs.
iterator insert_or_assign(const_iterator __hint, const key_type &__k, _Obj &&__obj)
Attempts to insert a std::pair into the unordered_map.
unordered_map(const allocator_type &__a)
Creates an unordered_map with no elements.
_Hashtable::key_type key_type
Public typedefs.
size_type bucket_count() const noexcept
Returns the number of buckets of the unordered_map.
iterator begin() noexcept
hasher hash_function() const
Returns the hash functor object with which the unordered_map was constructed.
auto equal_range(const _Kt &__x) const -> decltype(_M_h._M_equal_range_tr(__x))
Finds a subsequence matching given key.
unordered_map(initializer_list< value_type > __l, size_type __n=0, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type())
Builds an unordered_map from an initializer_list.
_Hashtable::const_iterator const_iterator
Iterator-related typedefs.
_Hashtable::size_type size_type
Iterator-related typedefs.
iterator find(const key_type &__x)
Tries to locate an element in an unordered_map.
float load_factor() const noexcept
Returns the average number of elements per bucket.
iterator erase(const_iterator __position)
Erases an element from an unordered_map.
void swap(unordered_map &__x) noexcept(noexcept(_M_h.swap(__x._M_h)))
Swaps data with another unordered_map.
local_iterator begin(size_type __n)
Returns a read/write iterator pointing to the first bucket element.
float max_load_factor() const noexcept
Returns a positive number that the unordered_map tries to keep the load factor less than or equal to.
unordered_map & operator=(const unordered_map &)=default
Copy assignment operator.
_Hashtable::difference_type difference_type
Iterator-related typedefs.
auto count(const _Kt &__x) const -> decltype(_M_h._M_count_tr(__x))
Finds the number of elements.
_Hashtable::const_local_iterator const_local_iterator
Iterator-related typedefs.
size_type max_bucket_count() const noexcept
Returns the maximum number of buckets of the unordered_map.
iterator emplace_hint(const_iterator __pos, _Args &&... __args)
Attempts to build and insert a std::pair into the unordered_map.
insert_return_type insert(node_type &&__nh)
Re-insert an extracted node.
_Hashtable::value_type value_type
Public typedefs.
void rehash(size_type __n)
May rehash the unordered_map.
const_iterator cbegin() const noexcept