30 #ifndef _UNORDERED_SET_H
31 #define _UNORDERED_SET_H
35 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
39 using __uset_traits = __detail::_Hashtable_traits<_Cache, true, true>;
41 template<
typename _Value,
42 typename _Hash = hash<_Value>,
43 typename _Pred = std::equal_to<_Value>,
44 typename _Alloc = std::allocator<_Value>,
45 typename _Tr = __uset_traits<__cache_default<_Value, _Hash>::value>>
46 using __uset_hashtable = _Hashtable<_Value, _Value, _Alloc,
47 __detail::_Identity, _Pred, _Hash,
48 __detail::_Mod_range_hashing,
49 __detail::_Default_ranged_hash,
50 __detail::_Prime_rehash_policy, _Tr>;
54 using __umset_traits = __detail::_Hashtable_traits<_Cache, true, false>;
56 template<
typename _Value,
57 typename _Hash = hash<_Value>,
58 typename _Pred = std::equal_to<_Value>,
59 typename _Alloc = std::allocator<_Value>,
60 typename _Tr = __umset_traits<__cache_default<_Value, _Hash>::value>>
61 using __umset_hashtable = _Hashtable<_Value, _Value, _Alloc,
64 __detail::_Mod_range_hashing,
65 __detail::_Default_ranged_hash,
66 __detail::_Prime_rehash_policy, _Tr>;
89 template<
class _Value,
90 class _Hash = hash<_Value>,
91 class _Pred = std::equal_to<_Value>,
92 class _Alloc = std::allocator<_Value> >
93 class unordered_set : __check_copy_constructible<_Alloc>
95 typedef __uset_hashtable<_Value, _Hash, _Pred, _Alloc> _Hashtable;
101 typedef typename _Hashtable::key_type key_type;
103 typedef typename _Hashtable::value_type value_type;
104 typedef typename _Hashtable::hasher hasher;
105 typedef typename _Hashtable::key_equal key_equal;
106 typedef typename _Hashtable::allocator_type allocator_type;
110 typedef typename allocator_type::pointer pointer;
112 typedef typename allocator_type::const_pointer const_pointer;
113 typedef typename allocator_type::reference reference;
114 typedef typename allocator_type::const_reference const_reference;
115 typedef typename _Hashtable::iterator iterator;
116 typedef typename _Hashtable::const_iterator const_iterator;
117 typedef typename _Hashtable::local_iterator local_iterator;
118 typedef typename _Hashtable::const_local_iterator const_local_iterator;
119 typedef typename _Hashtable::size_type size_type;
120 typedef typename _Hashtable::difference_type difference_type;
132 unordered_set(size_type __n = 10,
133 const hasher& __hf = hasher(),
134 const key_equal& __eql = key_equal(),
135 const allocator_type& __a = allocator_type())
136 : _M_h(__n, __hf, __eql, __a)
152 template<
typename _InputIterator>
153 unordered_set(_InputIterator __f, _InputIterator __l,
155 const hasher& __hf = hasher(),
156 const key_equal& __eql = key_equal(),
157 const allocator_type& __a = allocator_type())
158 : _M_h(__f, __l, __n, __hf, __eql, __a)
162 unordered_set(
const unordered_set&) =
default;
165 unordered_set(unordered_set&&) =
default;
178 unordered_set(initializer_list<value_type> __l,
180 const hasher& __hf = hasher(),
181 const key_equal& __eql = key_equal(),
182 const allocator_type& __a = allocator_type())
183 : _M_h(__l, __n, __hf, __eql, __a)
188 operator=(
const unordered_set&) =
default;
192 operator=(unordered_set&&) =
default;
206 operator=(initializer_list<value_type> __l)
215 get_allocator()
const noexcept
216 {
return _M_h.get_allocator(); }
222 empty()
const noexcept
223 {
return _M_h.empty(); }
227 size()
const noexcept
228 {
return _M_h.size(); }
232 max_size()
const noexcept
233 {
return _M_h.max_size(); }
244 {
return _M_h.begin(); }
247 begin()
const noexcept
248 {
return _M_h.begin(); }
258 {
return _M_h.end(); }
262 {
return _M_h.end(); }
270 cbegin()
const noexcept
271 {
return _M_h.begin(); }
278 cend()
const noexcept
279 {
return _M_h.end(); }
298 template<
typename... _Args>
299 std::pair<iterator, bool>
300 emplace(_Args&&... __args)
301 {
return _M_h.emplace(std::forward<_Args>(__args)...); }
324 template<
typename... _Args>
326 emplace_hint(const_iterator __pos, _Args&&... __args)
327 {
return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
343 std::pair<iterator, bool>
344 insert(
const value_type& __x)
345 {
return _M_h.insert(__x); }
347 std::pair<iterator, bool>
348 insert(value_type&& __x)
349 {
return _M_h.insert(std::move(__x)); }
373 insert(const_iterator __hint,
const value_type& __x)
374 {
return _M_h.insert(__hint, __x); }
377 insert(const_iterator __hint, value_type&& __x)
378 {
return _M_h.insert(__hint, std::move(__x)); }
390 template<
typename _InputIterator>
392 insert(_InputIterator __first, _InputIterator __last)
393 { _M_h.insert(__first, __last); }
403 insert(initializer_list<value_type> __l)
404 { _M_h.insert(__l); }
421 erase(const_iterator __position)
422 {
return _M_h.erase(__position); }
427 {
return _M_h.erase(__it); }
443 erase(
const key_type& __x)
444 {
return _M_h.erase(__x); }
461 erase(const_iterator __first, const_iterator __last)
462 {
return _M_h.erase(__first, __last); }
484 swap(unordered_set& __x)
485 { _M_h.swap(__x._M_h); }
492 hash_function()
const
493 {
return _M_h.hash_function(); }
499 {
return _M_h.key_eq(); }
516 find(
const key_type& __x)
517 {
return _M_h.find(__x); }
520 find(
const key_type& __x)
const
521 {
return _M_h.find(__x); }
534 count(
const key_type& __x)
const
535 {
return _M_h.count(__x); }
546 std::pair<iterator, iterator>
547 equal_range(
const key_type& __x)
548 {
return _M_h.equal_range(__x); }
550 std::pair<const_iterator, const_iterator>
551 equal_range(
const key_type& __x)
const
552 {
return _M_h.equal_range(__x); }
559 bucket_count()
const noexcept
560 {
return _M_h.bucket_count(); }
564 max_bucket_count()
const noexcept
565 {
return _M_h.max_bucket_count(); }
573 bucket_size(size_type __n)
const
574 {
return _M_h.bucket_size(__n); }
582 bucket(
const key_type& __key)
const
583 {
return _M_h.bucket(__key); }
594 {
return _M_h.begin(__n); }
597 begin(size_type __n)
const
598 {
return _M_h.begin(__n); }
601 cbegin(size_type __n)
const
602 {
return _M_h.cbegin(__n); }
614 {
return _M_h.end(__n); }
617 end(size_type __n)
const
618 {
return _M_h.end(__n); }
621 cend(size_type __n)
const
622 {
return _M_h.cend(__n); }
629 load_factor()
const noexcept
630 {
return _M_h.load_factor(); }
635 max_load_factor()
const noexcept
636 {
return _M_h.max_load_factor(); }
643 max_load_factor(
float __z)
644 { _M_h.max_load_factor(__z); }
654 rehash(size_type __n)
655 { _M_h.rehash(__n); }
665 reserve(size_type __n)
666 { _M_h.reserve(__n); }
668 template<
typename _Value1,
typename _Hash1,
typename _Pred1,
671 operator==(
const unordered_set<_Value1, _Hash1, _Pred1, _Alloc1>&,
672 const unordered_set<_Value1, _Hash1, _Pred1, _Alloc1>&);
694 template<
class _Value,
695 class _Hash = hash<_Value>,
696 class _Pred = std::equal_to<_Value>,
697 class _Alloc = std::allocator<_Value> >
698 class unordered_multiset : __check_copy_constructible<_Alloc>
700 typedef __umset_hashtable<_Value, _Hash, _Pred, _Alloc> _Hashtable;
706 typedef typename _Hashtable::key_type key_type;
708 typedef typename _Hashtable::value_type value_type;
709 typedef typename _Hashtable::hasher hasher;
710 typedef typename _Hashtable::key_equal key_equal;
711 typedef typename _Hashtable::allocator_type allocator_type;
715 typedef typename allocator_type::pointer pointer;
717 typedef typename allocator_type::const_pointer const_pointer;
718 typedef typename allocator_type::reference reference;
719 typedef typename allocator_type::const_reference const_reference;
720 typedef typename _Hashtable::iterator iterator;
721 typedef typename _Hashtable::const_iterator const_iterator;
722 typedef typename _Hashtable::local_iterator local_iterator;
723 typedef typename _Hashtable::const_local_iterator const_local_iterator;
724 typedef typename _Hashtable::size_type size_type;
725 typedef typename _Hashtable::difference_type difference_type;
737 unordered_multiset(size_type __n = 10,
738 const hasher& __hf = hasher(),
739 const key_equal& __eql = key_equal(),
740 const allocator_type& __a = allocator_type())
741 : _M_h(__n, __hf, __eql, __a)
757 template<
typename _InputIterator>
758 unordered_multiset(_InputIterator __f, _InputIterator __l,
760 const hasher& __hf = hasher(),
761 const key_equal& __eql = key_equal(),
762 const allocator_type& __a = allocator_type())
763 : _M_h(__f, __l, __n, __hf, __eql, __a)
767 unordered_multiset(
const unordered_multiset&) =
default;
770 unordered_multiset(unordered_multiset&&) =
default;
783 unordered_multiset(initializer_list<value_type> __l,
785 const hasher& __hf = hasher(),
786 const key_equal& __eql = key_equal(),
787 const allocator_type& __a = allocator_type())
788 : _M_h(__l, __n, __hf, __eql, __a)
793 operator=(
const unordered_multiset&) =
default;
797 operator=(unordered_multiset&& __x) =
default;
811 operator=(initializer_list<value_type> __l)
820 get_allocator()
const noexcept
821 {
return _M_h.get_allocator(); }
827 empty()
const noexcept
828 {
return _M_h.empty(); }
832 size()
const noexcept
833 {
return _M_h.size(); }
837 max_size()
const noexcept
838 {
return _M_h.max_size(); }
849 {
return _M_h.begin(); }
852 begin()
const noexcept
853 {
return _M_h.begin(); }
863 {
return _M_h.end(); }
867 {
return _M_h.end(); }
875 cbegin()
const noexcept
876 {
return _M_h.begin(); }
883 cend()
const noexcept
884 {
return _M_h.end(); }
895 template<
typename... _Args>
897 emplace(_Args&&... __args)
898 {
return _M_h.emplace(std::forward<_Args>(__args)...); }
917 template<
typename... _Args>
919 emplace_hint(const_iterator __pos, _Args&&... __args)
920 {
return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
931 insert(
const value_type& __x)
932 {
return _M_h.insert(__x); }
935 insert(value_type&& __x)
936 {
return _M_h.insert(std::move(__x)); }
957 insert(const_iterator __hint,
const value_type& __x)
958 {
return _M_h.insert(__hint, __x); }
961 insert(const_iterator __hint, value_type&& __x)
962 {
return _M_h.insert(__hint, std::move(__x)); }
973 template<
typename _InputIterator>
975 insert(_InputIterator __first, _InputIterator __last)
976 { _M_h.insert(__first, __last); }
986 insert(initializer_list<value_type> __l)
987 { _M_h.insert(__l); }
1005 erase(const_iterator __position)
1006 {
return _M_h.erase(__position); }
1010 erase(iterator __it)
1011 {
return _M_h.erase(__it); }
1028 erase(
const key_type& __x)
1029 {
return _M_h.erase(__x); }
1048 erase(const_iterator __first, const_iterator __last)
1049 {
return _M_h.erase(__first, __last); }
1072 swap(unordered_multiset& __x)
1073 { _M_h.swap(__x._M_h); }
1080 hash_function()
const
1081 {
return _M_h.hash_function(); }
1087 {
return _M_h.key_eq(); }
1104 find(
const key_type& __x)
1105 {
return _M_h.find(__x); }
1108 find(
const key_type& __x)
const
1109 {
return _M_h.find(__x); }
1118 count(
const key_type& __x)
const
1119 {
return _M_h.count(__x); }
1128 std::pair<iterator, iterator>
1129 equal_range(
const key_type& __x)
1130 {
return _M_h.equal_range(__x); }
1132 std::pair<const_iterator, const_iterator>
1133 equal_range(
const key_type& __x)
const
1134 {
return _M_h.equal_range(__x); }
1141 bucket_count()
const noexcept
1142 {
return _M_h.bucket_count(); }
1146 max_bucket_count()
const noexcept
1147 {
return _M_h.max_bucket_count(); }
1155 bucket_size(size_type __n)
const
1156 {
return _M_h.bucket_size(__n); }
1164 bucket(
const key_type& __key)
const
1165 {
return _M_h.bucket(__key); }
1175 begin(size_type __n)
1176 {
return _M_h.begin(__n); }
1178 const_local_iterator
1179 begin(size_type __n)
const
1180 {
return _M_h.begin(__n); }
1182 const_local_iterator
1183 cbegin(size_type __n)
const
1184 {
return _M_h.cbegin(__n); }
1196 {
return _M_h.end(__n); }
1198 const_local_iterator
1199 end(size_type __n)
const
1200 {
return _M_h.end(__n); }
1202 const_local_iterator
1203 cend(size_type __n)
const
1204 {
return _M_h.cend(__n); }
1211 load_factor()
const noexcept
1212 {
return _M_h.load_factor(); }
1217 max_load_factor()
const noexcept
1218 {
return _M_h.max_load_factor(); }
1225 max_load_factor(
float __z)
1226 { _M_h.max_load_factor(__z); }
1236 rehash(size_type __n)
1237 { _M_h.rehash(__n); }
1247 reserve(size_type __n)
1248 { _M_h.reserve(__n); }
1250 template<
typename _Value1,
typename _Hash1,
typename _Pred1,
1253 operator==(
const unordered_multiset<_Value1, _Hash1, _Pred1, _Alloc1>&,
1254 const unordered_multiset<_Value1, _Hash1, _Pred1, _Alloc1>&);
1257 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
1259 swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
1260 unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
1263 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
1265 swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1266 unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1269 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
1271 operator==(
const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
1272 const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
1273 {
return __x._M_h._M_equal(__y._M_h); }
1275 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
1277 operator!=(
const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
1278 const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
1279 {
return !(__x == __y); }
1281 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
1283 operator==(
const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1284 const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1285 {
return __x._M_h._M_equal(__y._M_h); }
1287 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
1289 operator!=(
const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1290 const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1291 {
return !(__x == __y); }
1293 _GLIBCXX_END_NAMESPACE_CONTAINER
bool operator==(const exception_ptr &, const exception_ptr &) _GLIBCXX_USE_NOEXCEPT __attribute__((__pure__))
bool operator!=(const exception_ptr &, const exception_ptr &) _GLIBCXX_USE_NOEXCEPT __attribute__((__pure__))
namespace std _GLIBCXX_VISIBILITY(default)
Definition: unordered_set.h:33
void swap(exception_ptr &__lhs, exception_ptr &__rhs)
Definition: exception_ptr.h:160