30 #ifndef _UNORDERED_SET_H 31 #define _UNORDERED_SET_H 37 #if __glibcxx_containers_ranges // C++ >= 23 41 namespace std _GLIBCXX_VISIBILITY(default)
43 _GLIBCXX_BEGIN_NAMESPACE_VERSION
44 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
50 template<
typename _Value,
55 using __uset_hashtable = _Hashtable<_Value, _Value, _Alloc,
56 __detail::_Identity, _Pred, _Hash,
57 __detail::_Mod_range_hashing,
58 __detail::_Default_ranged_hash,
59 __detail::_Prime_rehash_policy, _Tr>;
65 template<
typename _Value,
70 using __umset_hashtable = _Hashtable<_Value, _Value, _Alloc,
73 __detail::_Mod_range_hashing,
74 __detail::_Default_ranged_hash,
75 __detail::_Prime_rehash_policy, _Tr>;
77 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
103 template<
typename _Value,
109 typedef __uset_hashtable<_Value, _Hash, _Pred, _Alloc> _Hashtable;
118 typedef typename _Hashtable::hasher
hasher;
137 #ifdef __glibcxx_node_extract // >= C++17 && HOSTED 138 using node_type =
typename _Hashtable::node_type;
139 using insert_return_type =
typename _Hashtable::insert_return_type;
156 const hasher& __hf =
hasher(),
159 : _M_h(__n, __hf, __eql, __a)
175 template<
typename _InputIterator>
178 const hasher& __hf =
hasher(),
181 : _M_h(__first, __last, __n, __hf, __eql, __a)
205 const allocator_type& __a)
206 : _M_h(__uset._M_h, __a)
215 const allocator_type& __a)
216 noexcept( noexcept(_Hashtable(
std::move(__uset._M_h), __a)) )
233 const hasher& __hf =
hasher(),
236 : _M_h(__l, __n, __hf, __eql, __a)
244 const allocator_type& __a)
250 template<
typename _InputIterator>
252 const allocator_type& __a)
256 template<
typename _InputIterator>
259 const allocator_type& __a)
263 template<
typename _InputIterator>
265 size_type __n,
const hasher& __hf,
266 const allocator_type& __a)
274 const allocator_type& __a)
280 const allocator_type& __a)
285 size_type __n,
const hasher& __hf,
286 const allocator_type& __a)
290 #if __glibcxx_containers_ranges // C++ >= 23 304 template<__detail::__container_compatible_range<_Value> _Rg>
307 const hasher& __hf =
hasher(),
310 : _M_h(__n, __hf, __eql, __a)
311 { insert_range(std::forward<_Rg>(__rg)); }
315 template<__detail::__container_compatible_range<_Value> _Rg>
316 unordered_set(from_range_t, _Rg&& __rg,
const allocator_type& __a)
318 { insert_range(std::forward<_Rg>(__rg)); }
320 template<__detail::__container_compatible_range<_Value> _Rg>
322 const allocator_type& __a)
324 { insert_range(std::forward<_Rg>(__rg)); }
326 template<__detail::__container_compatible_range<_Value> _Rg>
328 const hasher& __hf,
const allocator_type& __a)
330 { insert_range(std::forward<_Rg>(__rg)); }
362 {
return _M_h.get_allocator(); }
367 _GLIBCXX_NODISCARD
bool 369 {
return _M_h.empty(); }
374 {
return _M_h.size(); }
379 {
return _M_h.max_size(); }
390 {
return _M_h.begin(); }
394 {
return _M_h.begin(); }
404 {
return _M_h.end(); }
408 {
return _M_h.end(); }
417 {
return _M_h.begin(); }
425 {
return _M_h.end(); }
444 template<
typename... _Args>
447 {
return _M_h.emplace(std::forward<_Args>(__args)...); }
470 template<
typename... _Args>
473 {
return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
491 {
return _M_h.insert(__x); }
497 #if __glibcxx_associative_heterogeneous_insertion // C++26 498 template <__heterogeneous_hash_key<unordered_set> _Kt>
501 {
return _M_h._M_insert_tr(std::forward<_Kt>(__x)); }
526 insert(const_iterator __hint,
const value_type& __x)
527 {
return _M_h.insert(__hint, __x); }
530 insert(const_iterator __hint, value_type&& __x)
531 {
return _M_h.insert(__hint,
std::move(__x)); }
533 #if __glibcxx_associative_heterogeneous_insertion // C++26 534 template <__heterogeneous_hash_key<unordered_set> _Kt>
536 insert(const_iterator, _Kt&& __x)
537 {
return _M_h._M_insert_tr(std::forward<_Kt>(__x)).first; }
550 template<
typename _InputIterator>
552 insert(_InputIterator __first, _InputIterator __last)
553 { _M_h.insert(__first, __last); }
564 { _M_h.insert(__l); }
566 #if __glibcxx_containers_ranges // C++ >= 23 573 template<__detail::__container_compatible_range<_Value> _Rg>
575 insert_range(_Rg&& __rg)
577 auto __first = ranges::begin(__rg);
578 const auto __last = ranges::end(__rg);
579 for (; __first != __last; ++__first)
580 _M_h.emplace(*__first);
584 #ifdef __glibcxx_node_extract // >= C++17 && HOSTED 589 __glibcxx_assert(__pos !=
end());
590 return _M_h.extract(__pos);
596 {
return _M_h.extract(__key); }
598 #ifdef __glibcxx_associative_heterogeneous_erasure // C++23 599 template <__heterogeneous_hash_key<unordered_set> _Kt>
602 {
return _M_h._M_extract_tr(__key); }
608 {
return _M_h._M_reinsert_node(
std::move(__nh)); }
613 {
return _M_h._M_reinsert_node(
std::move(__nh)).position; }
614 #endif // node_extract 632 {
return _M_h.erase(__position); }
637 {
return _M_h.erase(__position); }
654 {
return _M_h.erase(__x); }
656 #ifdef __glibcxx_associative_heterogeneous_erasure // C++23 657 template <__heterogeneous_hash_key<unordered_set> _Kt>
660 {
return _M_h._M_erase_tr(__key); }
678 erase(const_iterator __first, const_iterator __last)
679 {
return _M_h.erase(__first, __last); }
702 noexcept( noexcept(_M_h.swap(__x._M_h)) )
703 { _M_h.swap(__x._M_h); }
705 #ifdef __glibcxx_node_extract // >= C++17 && HOSTED 706 template<
typename,
typename,
typename>
707 friend class std::_Hash_merge_helper;
709 template<
typename _H2,
typename _P2>
713 if constexpr (is_same_v<_H2, _Hash> && is_same_v<_P2, _Pred>)
717 using _Merge_helper = _Hash_merge_helper<unordered_set, _H2, _P2>;
718 _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source));
721 template<
typename _H2,
typename _P2>
725 using _Merge_helper = _Hash_merge_helper<unordered_set, _H2, _P2>;
726 _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source));
729 template<
typename _H2,
typename _P2>
733 using _Merge_helper = _Hash_merge_helper<unordered_set, _H2, _P2>;
734 _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source));
737 template<
typename _H2,
typename _P2>
741 #endif // node_extract 749 {
return _M_h.hash_function(); }
755 {
return _M_h.key_eq(); }
773 {
return _M_h.find(__x); }
775 #ifdef __glibcxx_generic_unordered_lookup // C++ >= 20 && HOSTED 776 template<
typename _Kt>
779 -> decltype(_M_h._M_find_tr(__x))
780 {
return _M_h._M_find_tr(__x); }
784 find(
const key_type& __x)
const 785 {
return _M_h.find(__x); }
787 #ifdef __glibcxx_generic_unordered_lookup // C++ >= 20 && HOSTED 788 template<
typename _Kt>
791 -> decltype(_M_h._M_find_tr(__x))
792 {
return _M_h._M_find_tr(__x); }
808 {
return _M_h.count(__x); }
810 #ifdef __glibcxx_generic_unordered_lookup // C++ >= 20 && HOSTED 811 template<
typename _Kt>
814 -> decltype(_M_h._M_count_tr(__x))
815 {
return _M_h._M_count_tr(__x); }
819 #if __cplusplus > 201703L 828 {
return _M_h.find(__x) != _M_h.end(); }
830 template<
typename _Kt>
833 -> decltype(_M_h._M_find_tr(__x), void(),
true)
834 {
return _M_h._M_find_tr(__x) != _M_h.end(); }
849 {
return _M_h.equal_range(__x); }
851 #ifdef __glibcxx_generic_unordered_lookup // C++ >= 20 && HOSTED 852 template<
typename _Kt>
855 -> decltype(_M_h._M_equal_range_tr(__x))
856 {
return _M_h._M_equal_range_tr(__x); }
861 {
return _M_h.equal_range(__x); }
863 #ifdef __glibcxx_generic_unordered_lookup // C++ >= 20 && HOSTED 864 template<
typename _Kt>
867 -> decltype(_M_h._M_equal_range_tr(__x))
868 {
return _M_h._M_equal_range_tr(__x); }
877 {
return _M_h.bucket_count(); }
882 {
return _M_h.max_bucket_count(); }
890 bucket_size(size_type __n)
const 891 {
return _M_h.bucket_size(__n); }
900 bucket(
const key_type& __key)
const 901 {
return _M_h.bucket(__key); }
903 #if __glibcxx_associative_heterogeneous_insertion // C++26 904 template <__heterogeneous_hash_key<unordered_set> _Kt>
906 bucket(
const _Kt& __key)
const 907 {
return _M_h._M_bucket_tr(__key); }
920 {
return _M_h.begin(__n); }
924 {
return _M_h.begin(__n); }
928 {
return _M_h.cbegin(__n); }
940 {
return _M_h.end(__n); }
944 {
return _M_h.end(__n); }
948 {
return _M_h.cend(__n); }
956 {
return _M_h.load_factor(); }
962 {
return _M_h.max_load_factor(); }
970 { _M_h.max_load_factor(__z); }
981 { _M_h.rehash(__n); }
992 { _M_h.reserve(__n); }
994 template<
typename _Value1,
typename _Hash1,
typename _Pred1,
1001 #if __cpp_deduction_guides >= 201606 1003 template<
typename _InputIterator,
1008 typename _Allocator =
1010 typename = _RequireInputIter<_InputIterator>,
1011 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1012 typename = _RequireNotAllocator<_Pred>,
1013 typename = _RequireAllocator<_Allocator>>
1016 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1018 _Hash, _Pred, _Allocator>;
1020 template<
typename _Tp,
typename _Hash = hash<_Tp>,
1021 typename _Pred = equal_to<_Tp>,
1022 typename _Allocator = allocator<_Tp>,
1023 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1024 typename = _RequireNotAllocator<_Pred>,
1025 typename = _RequireAllocator<_Allocator>>
1028 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1031 template<
typename _InputIterator,
typename _Allocator,
1032 typename = _RequireInputIter<_InputIterator>,
1033 typename = _RequireAllocator<_Allocator>>
1040 typename iterator_traits<_InputIterator>::value_type>,
1045 template<
typename _InputIterator,
typename _Allocator,
1046 typename = _RequireInputIter<_InputIterator>,
1047 typename = _RequireAllocator<_Allocator>>
1051 typename iterator_traits<_InputIterator>::value_type>,
1053 typename iterator_traits<_InputIterator>::value_type>,
1056 template<
typename _InputIterator,
typename _Hash,
typename _Allocator,
1057 typename = _RequireInputIter<_InputIterator>,
1058 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1059 typename = _RequireAllocator<_Allocator>>
1066 typename iterator_traits<_InputIterator>::value_type>,
1069 template<
typename _Tp,
typename _Allocator,
1070 typename = _RequireAllocator<_Allocator>>
1077 template<
typename _Tp,
typename _Allocator,
1078 typename = _RequireAllocator<_Allocator>>
1082 template<
typename _Tp,
typename _Hash,
typename _Allocator,
1083 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1084 typename = _RequireAllocator<_Allocator>>
1089 #if __glibcxx_containers_ranges // C++ >= 23 1090 template<ranges::input_range _Rg,
1095 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1096 ->
unordered_set<ranges::range_value_t<_Rg>, _Hash, _Pred, _Allocator>;
1098 template<ranges::input_range _Rg,
1099 __allocator_like _Allocator>
1107 template<ranges::input_range _Rg,
1108 __allocator_like _Allocator>
1111 hash<ranges::range_value_t<_Rg>>,
1112 equal_to<ranges::range_value_t<_Rg>>,
1115 template<ranges::input_range _Rg,
1116 __not_allocator_like _Hash,
1117 __allocator_like _Allocator>
1121 equal_to<ranges::range_value_t<_Rg>>,
1147 template<
typename _Value,
1153 typedef __umset_hashtable<_Value, _Hash, _Pred, _Alloc> _Hashtable;
1181 #ifdef __glibcxx_node_extract // >= C++17 && HOSTED 1182 using node_type =
typename _Hashtable::node_type;
1199 const hasher& __hf =
hasher(),
1202 : _M_h(__n, __hf, __eql, __a)
1218 template<
typename _InputIterator>
1221 const hasher& __hf =
hasher(),
1224 : _M_h(__first, __last, __n, __hf, __eql, __a)
1246 const hasher& __hf =
hasher(),
1249 : _M_h(__l, __n, __hf, __eql, __a)
1275 const allocator_type& __a)
1276 : _M_h(__umset._M_h, __a)
1285 const allocator_type& __a)
1286 noexcept( noexcept(_Hashtable(
std::move(__umset._M_h), __a)) )
1295 const allocator_type& __a)
1301 template<
typename _InputIterator>
1303 const allocator_type& __a)
1307 template<
typename _InputIterator>
1310 const allocator_type& __a)
1314 template<
typename _InputIterator>
1316 size_type __n,
const hasher& __hf,
1317 const allocator_type& __a)
1324 const allocator_type& __a)
1330 const allocator_type& __a)
1335 size_type __n,
const hasher& __hf,
1336 const allocator_type& __a)
1340 #if __glibcxx_containers_ranges // C++ >= 23 1354 template<__detail::__container_compatible_range<_Value> _Rg>
1357 const hasher& __hf =
hasher(),
1360 : _M_h(__n, __hf, __eql, __a)
1361 { insert_range(std::forward<_Rg>(__rg)); }
1366 template<__detail::__container_compatible_range<_Value> _Rg>
1369 { insert_range(std::forward<_Rg>(__rg)); }
1371 template<__detail::__container_compatible_range<_Value> _Rg>
1373 const allocator_type& __a)
1375 { insert_range(std::forward<_Rg>(__rg)); }
1377 template<__detail::__container_compatible_range<_Value> _Rg>
1379 const hasher& __hf,
const allocator_type& __a)
1381 { insert_range(std::forward<_Rg>(__rg)); }
1406 {
return _M_h.get_allocator(); }
1411 _GLIBCXX_NODISCARD
bool 1413 {
return _M_h.empty(); }
1418 {
return _M_h.size(); }
1423 {
return _M_h.max_size(); }
1434 {
return _M_h.begin(); }
1438 {
return _M_h.begin(); }
1448 {
return _M_h.end(); }
1452 {
return _M_h.end(); }
1461 {
return _M_h.begin(); }
1469 {
return _M_h.end(); }
1480 template<
typename... _Args>
1483 {
return _M_h.emplace(std::forward<_Args>(__args)...); }
1502 template<
typename... _Args>
1505 {
return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
1517 {
return _M_h.insert(__x); }
1542 insert(const_iterator __hint,
const value_type& __x)
1543 {
return _M_h.insert(__hint, __x); }
1546 insert(const_iterator __hint, value_type&& __x)
1547 {
return _M_h.insert(__hint,
std::move(__x)); }
1558 template<
typename _InputIterator>
1560 insert(_InputIterator __first, _InputIterator __last)
1561 { _M_h.insert(__first, __last); }
1572 { _M_h.insert(__l); }
1574 #if __glibcxx_containers_ranges // C++ >= 23 1581 template<__detail::__container_compatible_range<_Value> _Rg>
1583 insert_range(_Rg&& __rg)
1585 auto __first = ranges::begin(__rg);
1586 const auto __last = ranges::end(__rg);
1587 if (__first == __last)
1590 if constexpr (ranges::forward_range<_Rg> || ranges::sized_range<_Rg>)
1591 _M_h._M_rehash_insert(
size_type(ranges::distance(__rg)));
1593 _M_h._M_rehash_insert(1);
1595 for (; __first != __last; ++__first)
1596 _M_h.emplace(*__first);
1600 #ifdef __glibcxx_node_extract // >= C++17 && HOSTED 1605 __glibcxx_assert(__pos !=
end());
1606 return _M_h.extract(__pos);
1612 {
return _M_h.extract(__key); }
1614 #ifdef __glibcxx_associative_heterogeneous_erasure // C++23 1615 template <__heterogeneous_hash_key<unordered_multiset> _Kt>
1618 {
return _M_h._M_extract_tr(__key); }
1624 {
return _M_h._M_reinsert_node_multi(
cend(),
std::move(__nh)); }
1628 insert(const_iterator __hint, node_type&& __nh)
1629 {
return _M_h._M_reinsert_node_multi(__hint,
std::move(__nh)); }
1630 #endif // node_extract 1649 {
return _M_h.erase(__position); }
1654 {
return _M_h.erase(__position); }
1672 {
return _M_h.erase(__x); }
1674 #ifdef __glibcxx_associative_heterogeneous_erasure // C++23 1675 template <__heterogeneous_hash_key<unordered_multiset> _Kt>
1678 {
return _M_h._M_erase_tr(__key); }
1698 erase(const_iterator __first, const_iterator __last)
1699 {
return _M_h.erase(__first, __last); }
1723 noexcept( noexcept(_M_h.swap(__x._M_h)) )
1724 { _M_h.swap(__x._M_h); }
1726 #ifdef __glibcxx_node_extract // >= C++17 && HOSTED 1727 template<
typename,
typename,
typename>
1728 friend class std::_Hash_merge_helper;
1730 template<
typename _H2,
typename _P2>
1734 if constexpr (is_same_v<_H2, _Hash> && is_same_v<_P2, _Pred>)
1739 = _Hash_merge_helper<unordered_multiset, _H2, _P2>;
1740 _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source));
1743 template<
typename _H2,
typename _P2>
1748 = _Hash_merge_helper<unordered_multiset, _H2, _P2>;
1749 _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source));
1752 template<
typename _H2,
typename _P2>
1757 = _Hash_merge_helper<unordered_multiset, _H2, _P2>;
1758 _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source));
1761 template<
typename _H2,
typename _P2>
1764 { merge(__source); }
1765 #endif // node_extract 1773 {
return _M_h.hash_function(); }
1779 {
return _M_h.key_eq(); }
1797 {
return _M_h.find(__x); }
1799 #ifdef __glibcxx_generic_unordered_lookup // C++ >= 20 && HOSTED 1800 template<
typename _Kt>
1803 -> decltype(_M_h._M_find_tr(__x))
1804 {
return _M_h._M_find_tr(__x); }
1809 {
return _M_h.find(__x); }
1811 #ifdef __glibcxx_generic_unordered_lookup // C++ >= 20 && HOSTED 1812 template<
typename _Kt>
1815 -> decltype(_M_h._M_find_tr(__x))
1816 {
return _M_h._M_find_tr(__x); }
1828 {
return _M_h.count(__x); }
1830 #ifdef __glibcxx_generic_unordered_lookup // C++ >= 20 && HOSTED 1831 template<
typename _Kt>
1833 count(
const _Kt& __x)
const -> decltype(_M_h._M_count_tr(__x))
1834 {
return _M_h._M_count_tr(__x); }
1838 #if __cplusplus > 201703L 1847 {
return _M_h.find(__x) != _M_h.end(); }
1849 template<
typename _Kt>
1852 -> decltype(_M_h._M_find_tr(__x), void(),
true)
1853 {
return _M_h._M_find_tr(__x) != _M_h.end(); }
1866 {
return _M_h.equal_range(__x); }
1868 #ifdef __glibcxx_generic_unordered_lookup // C++ >= 20 && HOSTED 1869 template<
typename _Kt>
1872 -> decltype(_M_h._M_equal_range_tr(__x))
1873 {
return _M_h._M_equal_range_tr(__x); }
1878 {
return _M_h.equal_range(__x); }
1880 #ifdef __glibcxx_generic_unordered_lookup // C++ >= 20 && HOSTED 1881 template<
typename _Kt>
1884 -> decltype(_M_h._M_equal_range_tr(__x))
1885 {
return _M_h._M_equal_range_tr(__x); }
1894 {
return _M_h.bucket_count(); }
1899 {
return _M_h.max_bucket_count(); }
1907 bucket_size(size_type __n)
const 1908 {
return _M_h.bucket_size(__n); }
1917 bucket(
const key_type& __key)
const 1918 {
return _M_h.bucket(__key); }
1920 #if __glibcxx_associative_heterogeneous_insertion // C++26 1921 template <__heterogeneous_hash_key<unordered_multiset> _Kt>
1923 bucket(
const _Kt& __key)
const 1924 {
return _M_h._M_bucket_tr(__key); }
1937 {
return _M_h.begin(__n); }
1939 const_local_iterator
1941 {
return _M_h.begin(__n); }
1943 const_local_iterator
1945 {
return _M_h.cbegin(__n); }
1957 {
return _M_h.end(__n); }
1959 const_local_iterator
1961 {
return _M_h.end(__n); }
1963 const_local_iterator
1965 {
return _M_h.cend(__n); }
1973 {
return _M_h.load_factor(); }
1979 {
return _M_h.max_load_factor(); }
1987 { _M_h.max_load_factor(__z); }
1998 { _M_h.rehash(__n); }
2009 { _M_h.reserve(__n); }
2011 template<
typename _Value1,
typename _Hash1,
typename _Pred1,
2019 #if __cpp_deduction_guides >= 201606 2021 template<
typename _InputIterator,
2026 typename _Allocator =
2028 typename = _RequireInputIter<_InputIterator>,
2029 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2030 typename = _RequireNotAllocator<_Pred>,
2031 typename = _RequireAllocator<_Allocator>>
2034 _Hash = _Hash(), _Pred = _Pred(),
2035 _Allocator = _Allocator())
2037 _Hash, _Pred, _Allocator>;
2039 template<
typename _Tp,
typename _Hash = hash<_Tp>,
2040 typename _Pred = equal_to<_Tp>,
2041 typename _Allocator = allocator<_Tp>,
2042 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2043 typename = _RequireNotAllocator<_Pred>,
2044 typename = _RequireAllocator<_Allocator>>
2047 _Hash = _Hash(), _Pred = _Pred(),
2048 _Allocator = _Allocator())
2051 template<
typename _InputIterator,
typename _Allocator,
2052 typename = _RequireInputIter<_InputIterator>,
2053 typename = _RequireAllocator<_Allocator>>
2058 iterator_traits<_InputIterator>::value_type>,
2060 iterator_traits<_InputIterator>::value_type>,
2065 template<
typename _InputIterator,
typename _Allocator,
2066 typename = _RequireInputIter<_InputIterator>,
2067 typename = _RequireAllocator<_Allocator>>
2071 iterator_traits<_InputIterator>::value_type>,
2073 iterator_traits<_InputIterator>::value_type>,
2076 template<
typename _InputIterator,
typename _Hash,
typename _Allocator,
2077 typename = _RequireInputIter<_InputIterator>,
2078 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2079 typename = _RequireAllocator<_Allocator>>
2084 iterator_traits<_InputIterator>::value_type,
2088 iterator_traits<_InputIterator>::value_type>,
2091 template<
typename _Tp,
typename _Allocator,
2092 typename = _RequireAllocator<_Allocator>>
2099 template<
typename _Tp,
typename _Allocator,
2100 typename = _RequireAllocator<_Allocator>>
2104 template<
typename _Tp,
typename _Hash,
typename _Allocator,
2105 typename = _RequireNotAllocatorOrIntegral<_Hash>,
2106 typename = _RequireAllocator<_Allocator>>
2111 #if __glibcxx_containers_ranges // C++ >= 23 2112 template<ranges::input_range _Rg,
2113 __not_allocator_like _Hash = hash<ranges::range_value_t<_Rg>>,
2114 __not_allocator_like _Pred = equal_to<ranges::range_value_t<_Rg>>,
2118 _Hash = _Hash(), _Pred = _Pred(),
2119 _Allocator = _Allocator())
2122 template<ranges::input_range _Rg,
2123 __allocator_like _Allocator>
2126 hash<ranges::range_value_t<_Rg>>,
2127 equal_to<ranges::range_value_t<_Rg>>,
2130 template<ranges::input_range _Rg,
2131 __allocator_like _Allocator>
2135 hash<ranges::range_value_t<_Rg>>,
2136 equal_to<ranges::range_value_t<_Rg>>,
2139 template<ranges::input_range _Rg,
2140 __not_allocator_like _Hash,
2141 __allocator_like _Allocator>
2146 equal_to<ranges::range_value_t<_Rg>>,
2151 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
2155 noexcept(noexcept(__x.
swap(__y)))
2158 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
2162 noexcept(noexcept(__x.
swap(__y)))
2165 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
2169 {
return __x._M_h._M_equal(__y._M_h); }
2171 #if __cpp_impl_three_way_comparison < 201907L 2172 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
2176 {
return !(__x == __y); }
2179 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
2183 {
return __x._M_h._M_equal(__y._M_h); }
2185 #if __cpp_impl_three_way_comparison < 201907L 2186 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
2190 {
return !(__x == __y); }
2193 _GLIBCXX_END_NAMESPACE_CONTAINER
2195 #ifdef __glibcxx_node_extract // >= C++17 && HOSTED 2197 template<
typename _Val,
typename _Hash1,
typename _Eq1,
typename _Alloc,
2198 typename _Hash2,
typename _Eq2>
2199 struct _Hash_merge_helper<
2200 _GLIBCXX_STD_C::
unordered_set<_Val, _Hash1, _Eq1, _Alloc>, _Hash2, _Eq2>
2203 template<
typename... _Tp>
2204 using unordered_set = _GLIBCXX_STD_C::unordered_set<_Tp...>;
2205 template<
typename... _Tp>
2212 {
return __set._M_h; }
2216 {
return __set._M_h; }
2220 template<
typename _Val,
typename _Hash1,
typename _Eq1,
typename _Alloc,
2221 typename _Hash2,
typename _Eq2>
2222 struct _Hash_merge_helper<
2227 template<
typename... _Tp>
2228 using unordered_set = _GLIBCXX_STD_C::unordered_set<_Tp...>;
2229 template<
typename... _Tp>
2236 {
return __set._M_h; }
2240 {
return __set._M_h; }
2242 #endif // node_extract 2244 _GLIBCXX_END_NAMESPACE_VERSION
_Hashtable::const_local_iterator const_local_iterator
Iterator-related typedefs.
const_iterator begin() const noexcept
_Hashtable::allocator_type allocator_type
Public typedefs.
const_local_iterator cbegin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
void insert(initializer_list< value_type > __l)
Inserts a list of elements into the unordered_multiset.
size_type bucket_count() const noexcept
Returns the number of buckets of the unordered_multiset.
unordered_multiset(size_type __n, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type())
Default constructor creates no elements.
auto count(const _Kt &__x) const -> decltype(_M_h._M_count_tr(__x))
Finds the number of elements.
const_local_iterator end(size_type __n) const
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
allocator_type get_allocator() const noexcept
Returns the allocator object used by the unordered_set.
_Hashtable::hasher hasher
Public typedefs.
node_type extract(const_iterator __pos)
Extract a node.
_Hashtable::const_iterator const_iterator
Iterator-related typedefs.
const_iterator end() const noexcept
hasher hash_function() const
Returns the hash functor object with which the unordered_multiset was constructed.
auto equal_range(const _Kt &__x) const -> decltype(_M_h._M_equal_range_tr(__x))
Finds a subsequence matching given key.
float max_load_factor() const noexcept
Returns a positive number that the unordered_multiset tries to keep the load factor less than or equa...
unordered_set(const allocator_type &__a)
Creates an unordered_set with no elements.
key_equal key_eq() const
Returns the key comparison object with which the unordered_multiset was constructed.
iterator begin() noexcept
iterator erase(iterator __position)
Erases an element from an unordered_set.
const_iterator begin() const noexcept
_Hashtable::const_pointer const_pointer
Iterator-related typedefs.
_Hashtable::size_type size_type
Iterator-related typedefs.
std::pair< iterator, bool > emplace(_Args &&... __args)
Attempts to build and insert an element into the unordered_set.
allocator_type get_allocator() const noexcept
Returns the allocator object used by the unordered_multiset.
_Hashtable::const_iterator const_iterator
Iterator-related typedefs.
unordered_set & operator=(const unordered_set &)=default
Copy assignment operator.
const_local_iterator cend(size_type __n) const
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
const_iterator cbegin() const noexcept
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
iterator erase(const_iterator __position)
Erases an element from an unordered_multiset.
void reserve(size_type __n)
Prepare the unordered_multiset for a specified number of elements.
iterator erase(const_iterator __position)
Erases an element from an unordered_set.
const_local_iterator begin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
size_type size() const noexcept
Returns the size of the unordered_set.
_Hashtable::difference_type difference_type
Iterator-related typedefs.
void rehash(size_type __n)
May rehash the unordered_set.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the unordered_set.
auto find(const _Kt &__x) -> decltype(_M_h._M_find_tr(__x))
Tries to locate an element in an unordered_set.
_Hashtable::const_pointer const_pointer
Iterator-related typedefs.
_Hashtable::local_iterator local_iterator
Iterator-related typedefs.
local_iterator begin(size_type __n)
Returns a read-only (constant) iterator pointing to the first bucket element.
insert_return_type insert(node_type &&__nh)
Re-insert an extracted node.
auto find(const _Kt &__x) const -> decltype(_M_h._M_find_tr(__x))
Tries to locate an element in an unordered_multiset.
float max_load_factor() const noexcept
Returns a positive number that the unordered_set tries to keep the load factor less than or equal to...
_Hashtable::reference reference
Iterator-related typedefs.
bool empty() const noexcept
Returns true if the unordered_set is empty.
void reserve(size_type __n)
Prepare the unordered_set for a specified number of elements.
auto count(const _Kt &__x) const -> decltype(_M_h._M_count_tr(__x))
Finds the number of elements.
unordered_set(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_set from an initializer_list.
std::pair< iterator, bool > insert(value_type &&__x)
Attempts to insert an element into the unordered_set.
_Hashtable::size_type size_type
Iterator-related typedefs.
unordered_set(size_type __n, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type())
Default constructor creates no elements.
iterator insert(const value_type &__x)
Inserts an element into the unordered_multiset.
_Hashtable::difference_type difference_type
Iterator-related typedefs.
_Hashtable::const_reference const_reference
Iterator-related typedefs.
void swap(unordered_multiset &__x) noexcept(noexcept(_M_h.swap(__x._M_h)))
Swaps data with another unordered_multiset.
iterator insert(const_iterator __hint, value_type &&__x)
Attempts to insert an element into the unordered_set.
void insert(_InputIterator __first, _InputIterator __last)
A template function that inserts a range of elements.
size_type bucket_count() const noexcept
Returns the number of buckets of the unordered_set.
void rehash(size_type __n)
May rehash the unordered_multiset.
unordered_set & operator=(initializer_list< value_type > __l)
Unordered_set list assignment operator.
iterator emplace_hint(const_iterator __pos, _Args &&... __args)
Attempts to insert an element into the unordered_set.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert an element into the unordered_set.
__detail::_Hashtable_traits< _Cache, true, true > __uset_traits
Base types for unordered_set.
size_type max_bucket_count() const noexcept
Returns the maximum number of buckets of the unordered_multiset.
node_type extract(const key_type &__key)
Extract a node.
_Hashtable::key_type key_type
Public typedefs.
size_type size() const noexcept
Returns the size of the unordered_multiset.
void insert(_InputIterator __first, _InputIterator __last)
A template function that attempts to insert a range of elements.
_Hashtable::pointer pointer
Iterator-related typedefs.
iterator insert(const_iterator __hint, value_type &&__x)
Inserts an element into the unordered_multiset.
const_iterator find(const key_type &__x) const
Tries to locate an element in an unordered_multiset.
_Hashtable::iterator iterator
Iterator-related typedefs.
unordered_set()=default
Default constructor.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
ISO C++ entities toplevel namespace is std.
auto find(const _Kt &__x) -> decltype(_M_h._M_find_tr(__x))
Tries to locate an element in an unordered_multiset.
_Hashtable::const_local_iterator const_local_iterator
Iterator-related typedefs.
node_type extract(const key_type &__key)
Extract a node.
key_equal key_eq() const
Returns the key comparison object with which the unordered_set was constructed.
const_local_iterator cbegin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
auto equal_range(const _Kt &__x) const -> decltype(_M_h._M_equal_range_tr(__x))
Finds a subsequence matching given key.
size_type max_size() const noexcept
Returns the maximum size of the unordered_multiset.
iterator find(const key_type &__x)
Tries to locate an element in an unordered_set.
_Hashtable::reference reference
Iterator-related typedefs.
Struct holding two objects of arbitrary type.
auto equal_range(const _Kt &__x) -> decltype(_M_h._M_equal_range_tr(__x))
Finds a subsequence matching given key.
void max_load_factor(float __z)
Change the unordered_multiset maximum load factor.
iterator insert(value_type &&__x)
Inserts an element into the unordered_multiset.
iterator insert(const_iterator __hint, const value_type &__x)
Attempts to insert an element into the unordered_set.
const_local_iterator cend(size_type __n) const
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
iterator erase(iterator __position)
Erases an element from an unordered_multiset.
iterator find(const key_type &__x)
Tries to locate an element in an unordered_multiset.
iterator emplace_hint(const_iterator __pos, _Args &&... __args)
Inserts an element into the unordered_multiset.
size_type count(const key_type &__x) const
Finds the number of elements.
A standard container composed of unique keys (containing at most one of each key value) in which the ...
_Hashtable::hasher hasher
Public typedefs.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
unordered_set(_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_set from a range.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
iterator insert(const_iterator __hint, const value_type &__x)
Inserts an element into the unordered_multiset.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
const_local_iterator end(size_type __n) const
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
_Hashtable::key_equal key_equal
Public typedefs.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
float load_factor() const noexcept
Returns the average number of elements per bucket.
local_iterator begin(size_type __n)
Returns a read-only (constant) iterator pointing to the first bucket element.
unordered_multiset(_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_multiset from a range.
_Hashtable::value_type value_type
Public typedefs.
hasher hash_function() const
Returns the hash functor object with which the unordered_set was constructed.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
const_iterator cbegin() const noexcept
void swap(unordered_set &__x) noexcept(noexcept(_M_h.swap(__x._M_h)))
Swaps data with another unordered_set.
iterator insert(const_iterator, node_type &&__nh)
Re-insert an extracted node.
node_type extract(const_iterator __pos)
Extract a node.
iterator insert(node_type &&__nh)
Re-insert an extracted node.
_Hashtable::const_reference const_reference
Iterator-related typedefs.
void max_load_factor(float __z)
Change the unordered_set maximum load factor.
A standard container composed of equivalent keys (possibly containing multiple of each key value) in ...
The standard allocator, as per C++03 [20.4.1].
Primary class template hash.
iterator erase(const_iterator __first, const_iterator __last)
Erases a [__first,__last) range of elements from an unordered_set.
auto equal_range(const _Kt &__x) -> decltype(_M_h._M_equal_range_tr(__x))
Finds a subsequence matching given key.
local_iterator end(size_type __n)
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
_Hashtable::value_type value_type
Public typedefs.
size_type max_size() const noexcept
Returns the maximum size of the unordered_set.
_Hashtable::key_type key_type
Public typedefs.
_Hashtable::key_equal key_equal
Public typedefs.
One of the comparison functors.
_Hashtable::local_iterator local_iterator
Iterator-related typedefs.
_Hashtable::allocator_type allocator_type
Public typedefs.
auto find(const _Kt &__x) const -> decltype(_M_h._M_find_tr(__x))
Tries to locate an element in an unordered_set.
size_type max_bucket_count() const noexcept
Returns the maximum number of buckets of the unordered_set.
const_local_iterator begin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
unordered_multiset(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_multiset from an initializer_list.
_Hashtable::iterator iterator
Iterator-related typedefs.
Traits class for iterators.
const_iterator end() const noexcept
__detail::_Hashtable_traits< _Cache, true, false > __umset_traits
Base types for unordered_multiset.
iterator begin() noexcept
bool contains(const key_type &__x) const
Finds whether an element with the given key exists.
bool empty() const noexcept
Returns true if the unordered_multiset is empty.
iterator emplace(_Args &&... __args)
Builds and insert an element into the unordered_multiset.
auto contains(const _Kt &__x) const -> decltype(_M_h._M_find_tr(__x), void(), true)
Finds whether an element with the given key exists.
auto contains(const _Kt &__x) const -> decltype(_M_h._M_find_tr(__x), void(), true)
Finds whether an element with the given key exists.
unordered_multiset(const allocator_type &__a)
Creates an unordered_multiset with no elements.
local_iterator end(size_type __n)
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
_Hashtable::pointer pointer
Iterator-related typedefs.
float load_factor() const noexcept
Returns the average number of elements per bucket.
unordered_multiset & operator=(initializer_list< value_type > __l)
Unordered_multiset list assignment operator.
size_type count(const key_type &__x) const
Finds the number of elements.
iterator erase(const_iterator __first, const_iterator __last)
Erases a [__first,__last) range of elements from an unordered_multiset.
const_iterator cend() const noexcept
iterator insert(const_iterator __hint, node_type &&__nh)
Re-insert an extracted node.
const_iterator find(const key_type &__x) const
Tries to locate an element in an unordered_set.
bool contains(const key_type &__x) const
Finds whether an element with the given key exists.
const_iterator cend() const noexcept