30 #ifndef _UNORDERED_SET_H
31 #define _UNORDERED_SET_H
33 namespace std _GLIBCXX_VISIBILITY(default)
35 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
41 template<
typename _Value,
47 __detail::_Identity, _Pred, _Hash,
56 template<
typename _Value,
68 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
92 template<
class _Value,
106 typedef typename _Hashtable::value_type value_type;
107 typedef typename _Hashtable::hasher hasher;
108 typedef typename _Hashtable::key_equal key_equal;
109 typedef typename _Hashtable::allocator_type allocator_type;
115 typedef typename _Hashtable::const_pointer const_pointer;
116 typedef typename _Hashtable::reference reference;
117 typedef typename _Hashtable::const_reference const_reference;
118 typedef typename _Hashtable::iterator iterator;
119 typedef typename _Hashtable::const_iterator const_iterator;
120 typedef typename _Hashtable::local_iterator local_iterator;
121 typedef typename _Hashtable::const_local_iterator const_local_iterator;
122 typedef typename _Hashtable::size_type size_type;
123 typedef typename _Hashtable::difference_type difference_type;
126 #if __cplusplus > 201402L
127 using node_type =
typename _Hashtable::node_type;
128 using insert_return_type =
typename _Hashtable::insert_return_type;
145 const hasher& __hf = hasher(),
146 const key_equal& __eql = key_equal(),
147 const allocator_type& __a = allocator_type())
148 : _M_h(__n, __hf, __eql, __a)
164 template<
typename _InputIterator>
167 const hasher& __hf = hasher(),
168 const key_equal& __eql = key_equal(),
169 const allocator_type& __a = allocator_type())
170 : _M_h(__first, __last, __n, __hf, __eql, __a)
194 const allocator_type& __a)
195 : _M_h(__uset._M_h, __a)
204 const allocator_type& __a)
205 : _M_h(
std::move(__uset._M_h), __a)
221 const hasher& __hf = hasher(),
222 const key_equal& __eql = key_equal(),
223 const allocator_type& __a = allocator_type())
224 : _M_h(__l, __n, __hf, __eql, __a)
232 const allocator_type& __a)
236 template<
typename _InputIterator>
239 const allocator_type& __a)
240 :
unordered_set(__first, __last, __n, hasher(), key_equal(), __a)
243 template<
typename _InputIterator>
245 size_type __n,
const hasher& __hf,
246 const allocator_type& __a)
247 :
unordered_set(__first, __last, __n, __hf, key_equal(), __a)
252 const allocator_type& __a)
257 size_type __n,
const hasher& __hf,
258 const allocator_type& __a)
291 {
return _M_h.get_allocator(); }
298 {
return _M_h.empty(); }
303 {
return _M_h.size(); }
308 {
return _M_h.max_size(); }
319 {
return _M_h.begin(); }
322 begin() const noexcept
323 {
return _M_h.begin(); }
333 {
return _M_h.end(); }
337 {
return _M_h.end(); }
346 {
return _M_h.begin(); }
354 {
return _M_h.end(); }
373 template<
typename... _Args>
376 {
return _M_h.emplace(std::forward<_Args>(__args)...); }
399 template<
typename... _Args>
402 {
return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
420 {
return _M_h.insert(__x); }
424 {
return _M_h.insert(std::move(__x)); }
448 insert(const_iterator __hint,
const value_type& __x)
449 {
return _M_h.insert(__hint, __x); }
452 insert(const_iterator __hint, value_type&& __x)
453 {
return _M_h.insert(__hint, std::move(__x)); }
465 template<
typename _InputIterator>
467 insert(_InputIterator __first, _InputIterator __last)
468 { _M_h.insert(__first, __last); }
479 { _M_h.insert(__l); }
481 #if __cplusplus > 201402L
484 extract(const_iterator __pos)
486 __glibcxx_assert(__pos !=
end());
487 return _M_h.extract(__pos);
493 {
return _M_h.extract(__key); }
498 {
return _M_h._M_reinsert_node(std::move(__nh)); }
502 insert(const_iterator, node_type&& __nh)
503 {
return _M_h._M_reinsert_node(std::move(__nh)).position; }
522 {
return _M_h.erase(__position); }
527 {
return _M_h.erase(__position); }
544 {
return _M_h.erase(__x); }
561 erase(const_iterator __first, const_iterator __last)
562 {
return _M_h.erase(__first, __last); }
585 noexcept( noexcept(_M_h.swap(__x._M_h)) )
586 { _M_h.swap(__x._M_h); }
588 #if __cplusplus > 201402L
589 template<
typename,
typename,
typename>
590 friend class _Hash_merge_helper;
592 template<
typename _H2,
typename _P2>
596 using _Merge_helper = _Hash_merge_helper<unordered_set, _H2, _P2>;
597 _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source));
600 template<
typename _H2,
typename _P2>
602 merge(unordered_set<_Value, _H2, _P2, _Alloc>&& __source)
605 template<
typename _H2,
typename _P2>
607 merge(unordered_multiset<_Value, _H2, _P2, _Alloc>& __source)
609 using _Merge_helper = _Hash_merge_helper<unordered_set, _H2, _P2>;
610 _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source));
613 template<
typename _H2,
typename _P2>
615 merge(unordered_multiset<_Value, _H2, _P2, _Alloc>&& __source)
625 {
return _M_h.hash_function(); }
631 {
return _M_h.key_eq(); }
649 {
return _M_h.find(__x); }
653 {
return _M_h.find(__x); }
667 {
return _M_h.count(__x); }
680 {
return _M_h.equal_range(__x); }
684 {
return _M_h.equal_range(__x); }
692 {
return _M_h.bucket_count(); }
697 {
return _M_h.max_bucket_count(); }
705 bucket_size(size_type __n)
const
706 {
return _M_h.bucket_size(__n); }
715 {
return _M_h.bucket(__key); }
726 {
return _M_h.begin(__n); }
729 begin(size_type __n)
const
730 {
return _M_h.begin(__n); }
733 cbegin(size_type __n)
const
734 {
return _M_h.cbegin(__n); }
746 {
return _M_h.end(__n); }
749 end(size_type __n)
const
750 {
return _M_h.end(__n); }
753 cend(size_type __n)
const
754 {
return _M_h.cend(__n); }
762 {
return _M_h.load_factor(); }
768 {
return _M_h.max_load_factor(); }
776 { _M_h.max_load_factor(__z); }
787 { _M_h.rehash(__n); }
798 { _M_h.reserve(__n); }
800 template<
typename _Value1,
typename _Hash1,
typename _Pred1,
826 template<
class _Value,
827 class _Hash = hash<_Value>,
840 typedef typename _Hashtable::value_type value_type;
841 typedef typename _Hashtable::hasher hasher;
842 typedef typename _Hashtable::key_equal key_equal;
843 typedef typename _Hashtable::allocator_type allocator_type;
849 typedef typename _Hashtable::const_pointer const_pointer;
850 typedef typename _Hashtable::reference reference;
851 typedef typename _Hashtable::const_reference const_reference;
852 typedef typename _Hashtable::iterator iterator;
853 typedef typename _Hashtable::const_iterator const_iterator;
854 typedef typename _Hashtable::local_iterator local_iterator;
855 typedef typename _Hashtable::const_local_iterator const_local_iterator;
856 typedef typename _Hashtable::size_type size_type;
857 typedef typename _Hashtable::difference_type difference_type;
860 #if __cplusplus > 201402L
861 using node_type =
typename _Hashtable::node_type;
878 const hasher& __hf = hasher(),
879 const key_equal& __eql = key_equal(),
880 const allocator_type& __a = allocator_type())
881 : _M_h(__n, __hf, __eql, __a)
897 template<
typename _InputIterator>
900 const hasher& __hf = hasher(),
901 const key_equal& __eql = key_equal(),
902 const allocator_type& __a = allocator_type())
903 : _M_h(__first, __last, __n, __hf, __eql, __a)
925 const hasher& __hf = hasher(),
926 const key_equal& __eql = key_equal(),
927 const allocator_type& __a = allocator_type())
928 : _M_h(__l, __n, __hf, __eql, __a)
954 const allocator_type& __a)
955 : _M_h(__umset._M_h, __a)
964 const allocator_type& __a)
965 : _M_h(
std::move(__umset._M_h), __a)
973 const allocator_type& __a)
977 template<
typename _InputIterator>
980 const allocator_type& __a)
984 template<
typename _InputIterator>
986 size_type __n,
const hasher& __hf,
987 const allocator_type& __a)
993 const allocator_type& __a)
998 size_type __n,
const hasher& __hf,
999 const allocator_type& __a)
1024 {
return _M_h.get_allocator(); }
1031 {
return _M_h.empty(); }
1036 {
return _M_h.size(); }
1041 {
return _M_h.max_size(); }
1052 {
return _M_h.begin(); }
1055 begin() const noexcept
1056 {
return _M_h.begin(); }
1066 {
return _M_h.end(); }
1069 end() const noexcept
1070 {
return _M_h.end(); }
1079 {
return _M_h.begin(); }
1087 {
return _M_h.end(); }
1098 template<
typename... _Args>
1101 {
return _M_h.emplace(std::forward<_Args>(__args)...); }
1120 template<
typename... _Args>
1123 {
return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
1135 {
return _M_h.insert(__x); }
1139 {
return _M_h.insert(std::move(__x)); }
1160 insert(const_iterator __hint,
const value_type& __x)
1161 {
return _M_h.insert(__hint, __x); }
1164 insert(const_iterator __hint, value_type&& __x)
1165 {
return _M_h.insert(__hint, std::move(__x)); }
1176 template<
typename _InputIterator>
1178 insert(_InputIterator __first, _InputIterator __last)
1179 { _M_h.insert(__first, __last); }
1190 { _M_h.insert(__l); }
1192 #if __cplusplus > 201402L
1195 extract(const_iterator __pos)
1197 __glibcxx_assert(__pos !=
end());
1198 return _M_h.extract(__pos);
1204 {
return _M_h.extract(__key); }
1209 {
return _M_h._M_reinsert_node_multi(
cend(), std::move(__nh)); }
1213 insert(const_iterator __hint, node_type&& __nh)
1214 {
return _M_h._M_reinsert_node_multi(__hint, std::move(__nh)); }
1234 {
return _M_h.erase(__position); }
1239 {
return _M_h.erase(__position); }
1257 {
return _M_h.erase(__x); }
1276 erase(const_iterator __first, const_iterator __last)
1277 {
return _M_h.erase(__first, __last); }
1301 noexcept( noexcept(_M_h.swap(__x._M_h)) )
1302 { _M_h.swap(__x._M_h); }
1304 #if __cplusplus > 201402L
1305 template<
typename,
typename,
typename>
1306 friend class _Hash_merge_helper;
1308 template<
typename _H2,
typename _P2>
1313 = _Hash_merge_helper<unordered_multiset, _H2, _P2>;
1314 _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source));
1317 template<
typename _H2,
typename _P2>
1319 merge(unordered_multiset<_Value, _H2, _P2, _Alloc>&& __source)
1320 { merge(__source); }
1322 template<
typename _H2,
typename _P2>
1324 merge(unordered_set<_Value, _H2, _P2, _Alloc>& __source)
1327 = _Hash_merge_helper<unordered_multiset, _H2, _P2>;
1328 _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source));
1331 template<
typename _H2,
typename _P2>
1333 merge(unordered_set<_Value, _H2, _P2, _Alloc>&& __source)
1334 { merge(__source); }
1343 {
return _M_h.hash_function(); }
1349 {
return _M_h.key_eq(); }
1367 {
return _M_h.find(__x); }
1371 {
return _M_h.find(__x); }
1381 {
return _M_h.count(__x); }
1392 {
return _M_h.equal_range(__x); }
1396 {
return _M_h.equal_range(__x); }
1404 {
return _M_h.bucket_count(); }
1409 {
return _M_h.max_bucket_count(); }
1417 bucket_size(size_type __n)
const
1418 {
return _M_h.bucket_size(__n); }
1426 bucket(
const key_type& __key)
const
1427 {
return _M_h.bucket(__key); }
1438 {
return _M_h.begin(__n); }
1440 const_local_iterator
1441 begin(size_type __n)
const
1442 {
return _M_h.begin(__n); }
1444 const_local_iterator
1445 cbegin(size_type __n)
const
1446 {
return _M_h.cbegin(__n); }
1458 {
return _M_h.end(__n); }
1460 const_local_iterator
1461 end(size_type __n)
const
1462 {
return _M_h.end(__n); }
1464 const_local_iterator
1465 cend(size_type __n)
const
1466 {
return _M_h.cend(__n); }
1474 {
return _M_h.load_factor(); }
1480 {
return _M_h.max_load_factor(); }
1488 { _M_h.max_load_factor(__z); }
1499 { _M_h.rehash(__n); }
1510 { _M_h.reserve(__n); }
1512 template<
typename _Value1,
typename _Hash1,
typename _Pred1,
1519 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
1521 swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
1522 unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
1523 noexcept(noexcept(__x.swap(__y)))
1526 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
1528 swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1529 unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1530 noexcept(noexcept(__x.swap(__y)))
1533 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
1535 operator==(
const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
1536 const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
1537 {
return __x._M_h._M_equal(__y._M_h); }
1539 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
1541 operator!=(
const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
1542 const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
1543 {
return !(__x == __y); }
1545 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
1547 operator==(
const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1548 const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1549 {
return __x._M_h._M_equal(__y._M_h); }
1551 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
1553 operator!=(
const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1554 const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1555 {
return !(__x == __y); }
1557 _GLIBCXX_END_NAMESPACE_CONTAINER
1559 #if __cplusplus > 201402L
1560 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1562 template<
typename _Val,
typename _Hash1,
typename _Eq1,
typename _Alloc,
1563 typename _Hash2,
typename _Eq2>
1564 struct _Hash_merge_helper<
1565 _GLIBCXX_STD_C::unordered_set<_Val, _Hash1, _Eq1, _Alloc>, _Hash2, _Eq2>
1568 template<
typename... _Tp>
1569 using unordered_set = _GLIBCXX_STD_C::unordered_set<_Tp...>;
1570 template<
typename... _Tp>
1571 using unordered_multiset = _GLIBCXX_STD_C::unordered_multiset<_Tp...>;
1573 friend unordered_set<_Val, _Hash1, _Eq1, _Alloc>;
1576 _S_get_table(unordered_set<_Val, _Hash2, _Eq2, _Alloc>& __set)
1577 {
return __set._M_h; }
1580 _S_get_table(unordered_multiset<_Val, _Hash2, _Eq2, _Alloc>& __set)
1581 {
return __set._M_h; }
1585 template<
typename _Val,
typename _Hash1,
typename _Eq1,
typename _Alloc,
1586 typename _Hash2,
typename _Eq2>
1587 struct _Hash_merge_helper<
1588 _GLIBCXX_STD_C::unordered_multiset<_Val, _Hash1, _Eq1, _Alloc>,
1592 template<
typename... _Tp>
1593 using unordered_set = _GLIBCXX_STD_C::unordered_set<_Tp...>;
1594 template<
typename... _Tp>
1595 using unordered_multiset = _GLIBCXX_STD_C::unordered_multiset<_Tp...>;
1597 friend unordered_multiset<_Val, _Hash1, _Eq1, _Alloc>;
1600 _S_get_table(unordered_set<_Val, _Hash2, _Eq2, _Alloc>& __set)
1601 {
return __set._M_h; }
1604 _S_get_table(unordered_multiset<_Val, _Hash2, _Eq2, _Alloc>& __set)
1605 {
return __set._M_h; }
1607 _GLIBCXX_END_NAMESPACE_VERSION