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,
64 __detail::_Mod_range_hashing,
65 __detail::_Default_ranged_hash,
66 __detail::_Prime_rehash_policy, _Tr>;
89 template<
class _Value,
104 typedef typename _Hashtable::hasher
hasher;
137 const hasher& __hf =
hasher(),
140 : _M_h(__n, __hf, __eql, __a)
156 template<
typename _InputIterator>
159 const hasher& __hf =
hasher(),
162 : _M_h(__first, __last, __n, __hf, __eql, __a)
186 const allocator_type& __a)
187 : _M_h(__uset._M_h, __a)
196 const allocator_type& __a)
197 : _M_h(std::move(__uset._M_h), __a)
213 const hasher& __hf =
hasher(),
216 : _M_h(__l, __n, __hf, __eql, __a)
224 const allocator_type& __a)
228 template<
typename _InputIterator>
231 const allocator_type& __a)
235 template<
typename _InputIterator>
237 size_type __n,
const hasher& __hf,
238 const allocator_type& __a)
244 const allocator_type& __a)
249 size_type __n,
const hasher& __hf,
250 const allocator_type& __a)
284 {
return _M_h.get_allocator(); }
291 {
return _M_h.empty(); }
296 {
return _M_h.size(); }
301 {
return _M_h.max_size(); }
312 {
return _M_h.begin(); }
316 {
return _M_h.begin(); }
326 {
return _M_h.end(); }
330 {
return _M_h.end(); }
339 {
return _M_h.begin(); }
347 {
return _M_h.end(); }
366 template<
typename... _Args>
369 {
return _M_h.emplace(std::forward<_Args>(__args)...); }
392 template<
typename... _Args>
395 {
return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
413 {
return _M_h.insert(__x); }
417 {
return _M_h.insert(std::move(__x)); }
441 insert(const_iterator __hint,
const value_type& __x)
442 {
return _M_h.insert(__hint, __x); }
445 insert(const_iterator __hint, value_type&& __x)
446 {
return _M_h.insert(__hint, std::move(__x)); }
458 template<
typename _InputIterator>
460 insert(_InputIterator __first, _InputIterator __last)
461 { _M_h.insert(__first, __last); }
472 { _M_h.insert(__l); }
490 {
return _M_h.erase(__position); }
495 {
return _M_h.erase(__position); }
512 {
return _M_h.erase(__x); }
529 erase(const_iterator __first, const_iterator __last)
530 {
return _M_h.erase(__first, __last); }
553 noexcept( noexcept(_M_h.swap(__x._M_h)) )
554 { _M_h.swap(__x._M_h); }
562 {
return _M_h.hash_function(); }
568 {
return _M_h.key_eq(); }
586 {
return _M_h.find(__x); }
589 find(
const key_type& __x)
const 590 {
return _M_h.find(__x); }
604 {
return _M_h.count(__x); }
617 {
return _M_h.equal_range(__x); }
621 {
return _M_h.equal_range(__x); }
629 {
return _M_h.bucket_count(); }
634 {
return _M_h.max_bucket_count(); }
642 bucket_size(size_type __n)
const 643 {
return _M_h.bucket_size(__n); }
651 bucket(
const key_type& __key)
const 652 {
return _M_h.bucket(__key); }
663 {
return _M_h.begin(__n); }
667 {
return _M_h.begin(__n); }
671 {
return _M_h.cbegin(__n); }
683 {
return _M_h.end(__n); }
687 {
return _M_h.end(__n); }
691 {
return _M_h.cend(__n); }
699 {
return _M_h.load_factor(); }
705 {
return _M_h.max_load_factor(); }
713 { _M_h.max_load_factor(__z); }
724 { _M_h.rehash(__n); }
735 { _M_h.reserve(__n); }
737 template<
typename _Value1,
typename _Hash1,
typename _Pred1,
763 template<
class _Value,
778 typedef typename _Hashtable::hasher
hasher;
811 const hasher& __hf =
hasher(),
814 : _M_h(__n, __hf, __eql, __a)
830 template<
typename _InputIterator>
833 const hasher& __hf =
hasher(),
836 : _M_h(__first, __last, __n, __hf, __eql, __a)
858 const hasher& __hf =
hasher(),
861 : _M_h(__l, __n, __hf, __eql, __a)
887 const allocator_type& __a)
888 : _M_h(__umset._M_h, __a)
897 const allocator_type& __a)
898 : _M_h(std::move(__umset._M_h), __a)
906 const allocator_type& __a)
910 template<
typename _InputIterator>
913 const allocator_type& __a)
917 template<
typename _InputIterator>
919 size_type __n,
const hasher& __hf,
920 const allocator_type& __a)
926 const allocator_type& __a)
931 size_type __n,
const hasher& __hf,
932 const allocator_type& __a)
958 {
return _M_h.get_allocator(); }
965 {
return _M_h.empty(); }
970 {
return _M_h.size(); }
975 {
return _M_h.max_size(); }
986 {
return _M_h.begin(); }
990 {
return _M_h.begin(); }
1000 {
return _M_h.end(); }
1004 {
return _M_h.end(); }
1013 {
return _M_h.begin(); }
1021 {
return _M_h.end(); }
1032 template<
typename... _Args>
1035 {
return _M_h.emplace(std::forward<_Args>(__args)...); }
1054 template<
typename... _Args>
1057 {
return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
1069 {
return _M_h.insert(__x); }
1073 {
return _M_h.insert(std::move(__x)); }
1094 insert(const_iterator __hint,
const value_type& __x)
1095 {
return _M_h.insert(__hint, __x); }
1098 insert(const_iterator __hint, value_type&& __x)
1099 {
return _M_h.insert(__hint, std::move(__x)); }
1110 template<
typename _InputIterator>
1112 insert(_InputIterator __first, _InputIterator __last)
1113 { _M_h.insert(__first, __last); }
1124 { _M_h.insert(__l); }
1143 {
return _M_h.erase(__position); }
1148 {
return _M_h.erase(__position); }
1166 {
return _M_h.erase(__x); }
1185 erase(const_iterator __first, const_iterator __last)
1186 {
return _M_h.erase(__first, __last); }
1210 noexcept( noexcept(_M_h.swap(__x._M_h)) )
1211 { _M_h.swap(__x._M_h); }
1219 {
return _M_h.hash_function(); }
1225 {
return _M_h.key_eq(); }
1243 {
return _M_h.find(__x); }
1247 {
return _M_h.find(__x); }
1257 {
return _M_h.count(__x); }
1268 {
return _M_h.equal_range(__x); }
1272 {
return _M_h.equal_range(__x); }
1280 {
return _M_h.bucket_count(); }
1285 {
return _M_h.max_bucket_count(); }
1293 bucket_size(size_type __n)
const 1294 {
return _M_h.bucket_size(__n); }
1302 bucket(
const key_type& __key)
const 1303 {
return _M_h.bucket(__key); }
1314 {
return _M_h.begin(__n); }
1316 const_local_iterator
1318 {
return _M_h.begin(__n); }
1320 const_local_iterator
1322 {
return _M_h.cbegin(__n); }
1334 {
return _M_h.end(__n); }
1336 const_local_iterator
1338 {
return _M_h.end(__n); }
1340 const_local_iterator
1342 {
return _M_h.cend(__n); }
1350 {
return _M_h.load_factor(); }
1356 {
return _M_h.max_load_factor(); }
1364 { _M_h.max_load_factor(__z); }
1375 { _M_h.rehash(__n); }
1386 { _M_h.reserve(__n); }
1388 template<
typename _Value1,
typename _Hash1,
typename _Pred1,
1395 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
1399 noexcept(noexcept(__x.
swap(__y)))
1402 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
1406 noexcept(noexcept(__x.
swap(__y)))
1409 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
1413 {
return __x._M_h._M_equal(__y._M_h); }
1415 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
1419 {
return !(__x == __y); }
1421 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
1425 {
return __x._M_h._M_equal(__y._M_h); }
1427 template<
class _Value,
class _Hash,
class _Pred,
class _Alloc>
1431 {
return !(__x == __y); }
1433 _GLIBCXX_END_NAMESPACE_CONTAINER
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.
unordered_set(const allocator_type &__a)
Creates an unordered_set with no elements.
size_type size() const noexcept
Returns the size of the unordered_set.
iterator insert(const_iterator __hint, const value_type &__x)
Attempts to insert an element into the unordered_set.
allocator_type get_allocator() const noexcept
Returns the allocator object with which the unordered_set was constructed.
void swap(unordered_set &__x) noexcept(noexcept(_M_h.swap(__x._M_h)))
Swaps data with another unordered_set.
iterator insert(const value_type &__x)
Inserts an element into the unordered_multiset.
_Hashtable::const_pointer const_pointer
Iterator-related typedefs.
const_iterator begin() const noexcept
The standard allocator, as per [20.4].
const_local_iterator cbegin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
void reserve(size_type __n)
Prepare the unordered_multiset for a specified number of elements.
hasher hash_function() const
Returns the hash functor object with which the unordered_set was constructed.
const_iterator cbegin() const noexcept
iterator erase(iterator __position)
Erases an element from an unordered_multiset.
_Hashtable::const_reference const_reference
Iterator-related typedefs.
_Hashtable::const_iterator const_iterator
Iterator-related typedefs.
void insert(initializer_list< value_type > __l)
Inserts a list of elements into the unordered_multiset.
_Hashtable::hasher hasher
Public typedefs.
iterator erase(const_iterator __first, const_iterator __last)
Erases a [__first,__last) range of elements from an unordered_set.
iterator begin() noexcept
_Hashtable::allocator_type allocator_type
Public typedefs.
_Hashtable::difference_type difference_type
Iterator-related typedefs.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert an element into the unordered_set.
const_iterator cend() const noexcept
_Hashtable::local_iterator local_iterator
Iterator-related typedefs.
iterator erase(const_iterator __position)
Erases an element from an unordered_set.
Default value for rehash policy. Bucket size is (usually) the smallest prime that keeps the load fact...
_Hashtable::key_type key_type
Public typedefs.
iterator emplace_hint(const_iterator __pos, _Args &&...__args)
Inserts an element into the unordered_multiset.
std::pair< iterator, bool > emplace(_Args &&...__args)
Attempts to build and insert an element into the unordered_set.
A standard container composed of unique keys (containing at most one of each key value) in which the ...
size_type bucket_count() const noexcept
Returns the number of buckets of the unordered_set.
_Hashtable::reference reference
Iterator-related typedefs.
unordered_multiset(const allocator_type &__a)
Creates an unordered_multiset with no elements.
const_local_iterator cend(size_type __n) const
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
size_type max_bucket_count() const noexcept
Returns the maximum number of buckets of the unordered_multiset.
iterator erase(const_iterator __position)
Erases an element from an unordered_multiset.
allocator_type get_allocator() const noexcept
Returns the allocator object with which the unordered_multiset was constructed.
const_iterator find(const key_type &__x) const
Tries to locate an element in an unordered_multiset.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
One of the comparison functors.
size_type size() const noexcept
Returns the size of the unordered_multiset.
const_iterator begin() const noexcept
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
bool empty() const noexcept
Returns true if the unordered_set is empty.
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.
const_local_iterator begin(size_type __n) const
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::const_local_iterator const_local_iterator
Iterator-related typedefs.
iterator emplace_hint(const_iterator __pos, _Args &&...__args)
Attempts to insert an element into the unordered_set.
const_local_iterator end(size_type __n) const
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
size_type bucket_count() const noexcept
Returns the number of buckets of the unordered_multiset.
void rehash(size_type __n)
May rehash the unordered_set.
unordered_set & operator=(const unordered_set &)=default
Copy assignment operator.
void reserve(size_type __n)
Prepare the unordered_set for a specified number of elements.
void insert(_InputIterator __first, _InputIterator __last)
A template function that attempts to insert a range of elements.
iterator insert(const_iterator __hint, value_type &&__x)
Attempts to insert an element into the unordered_set.
unordered_set()=default
Default constructor.
local_iterator begin(size_type __n)
Returns a read-only (constant) iterator pointing to the first bucket element.
_Hashtable::size_type size_type
Iterator-related typedefs.
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...
const_iterator cbegin() const noexcept
iterator erase(iterator __position)
Erases an element from an unordered_set.
_Hashtable::pointer pointer
Iterator-related typedefs.
local_iterator end(size_type __n)
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
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.
iterator find(const key_type &__x)
Tries to locate an element in an unordered_multiset.
size_type count(const key_type &__x) const
Finds the number of elements.
void swap(unordered_multiset &__x) noexcept(noexcept(_M_h.swap(__x._M_h)))
Swaps data with another unordered_multiset.
_Hashtable::difference_type difference_type
Iterator-related typedefs.
const_local_iterator end(size_type __n) const
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
_Hashtable::hasher hasher
Public typedefs.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
const_iterator end() const noexcept
_Hashtable::local_iterator local_iterator
Iterator-related typedefs.
hasher hash_function() const
Returns the hash functor object with which the unordered_multiset was constructed.
void max_load_factor(float __z)
Change the unordered_set maximum load factor.
local_iterator end(size_type __n)
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
Default range hashing function: use division to fold a large number into the range [0...
_Hashtable::iterator iterator
Iterator-related typedefs.
size_type count(const key_type &__x) const
Finds the number of elements.
_Hashtable::const_pointer const_pointer
Iterator-related typedefs.
Struct holding two objects of arbitrary type.
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.
_Hashtable::pointer pointer
Iterator-related typedefs.
size_type max_size() const noexcept
Returns the maximum size of the unordered_multiset.
A standard container composed of equivalent keys (possibly containing multiple of each key value) in ...
_Hashtable::key_type key_type
Public typedefs.
_Hashtable::reference reference
Iterator-related typedefs.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the unordered_set.
_Hashtable::const_iterator const_iterator
Iterator-related typedefs.
float max_load_factor() const noexcept
Returns a positive number that the unordered_multiset tries to keep the load factor less than or equa...
iterator emplace(_Args &&...__args)
Builds and insert an element into the unordered_multiset.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
void rehash(size_type __n)
May rehash the unordered_multiset.
_Hashtable::value_type value_type
Public typedefs.
const_local_iterator cend(size_type __n) const
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
unordered_multiset & operator=(initializer_list< value_type > __l)
Unordered_multiset list assignment operator.
_Hashtable::iterator iterator
Iterator-related typedefs.
key_equal key_eq() const
Returns the key comparison object with which the unordered_multiset was constructed.
iterator find(const key_type &__x)
Tries to locate an element in an unordered_set.
const_local_iterator begin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
local_iterator begin(size_type __n)
Returns a read-only (constant) iterator pointing to the first bucket element.
iterator insert(value_type &&__x)
Inserts an element into the unordered_multiset.
_Hashtable::key_equal key_equal
Public typedefs.
float load_factor() const noexcept
Returns the average number of elements per bucket.
void max_load_factor(float __z)
Change the unordered_multiset maximum load factor.
_Hashtable::allocator_type allocator_type
Public typedefs.
key_equal key_eq() const
Returns the key comparison object with which the unordered_set was constructed.
unordered_set & operator=(initializer_list< value_type > __l)
Unordered_set list assignment operator.
float load_factor() const noexcept
Returns the average number of elements per bucket.
const_iterator find(const key_type &__x) const
Tries to locate an element in an unordered_set.
_Hashtable::const_local_iterator const_local_iterator
Iterator-related typedefs.
void insert(_InputIterator __first, _InputIterator __last)
A template function that inserts a range of elements.
iterator insert(const_iterator __hint, value_type &&__x)
Inserts an element into the unordered_multiset.
size_type max_bucket_count() const noexcept
Returns the maximum number of buckets of the unordered_set.
size_type max_size() const noexcept
Returns the maximum size of the unordered_set.
iterator insert(const_iterator __hint, const value_type &__x)
Inserts an element into the unordered_multiset.
iterator begin() noexcept
_Hashtable::const_reference const_reference
Iterator-related typedefs.
_Hashtable::key_equal key_equal
Public typedefs.
const_local_iterator cbegin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
const_iterator cend() const noexcept
ISO C++ entities toplevel namespace is std.
Primary class template hash.
bool empty() const noexcept
Returns true if the unordered_multiset is empty.
std::pair< iterator, bool > insert(value_type &&__x)
Attempts to insert an element into the unordered_set.
const_iterator end() const noexcept
size_type erase(const key_type &__x)
Erases elements according to the provided key.
Default ranged hash function H. In principle it should be a function object composed from objects of ...
iterator erase(const_iterator __first, const_iterator __last)
Erases a [__first,__last) range of elements from an unordered_multiset.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
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.
_Hashtable::size_type size_type
Iterator-related typedefs.
_Hashtable::value_type value_type
Public typedefs.