30 #ifndef _UNORDERED_MAP_H
31 #define _UNORDERED_MAP_H
33 namespace std _GLIBCXX_VISIBILITY(default)
35 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
41 template<
typename _Key,
48 _Alloc, __detail::_Select1st,
58 template<
typename _Key,
65 _Alloc, __detail::_Select1st,
67 __detail::_Mod_range_hashing,
68 __detail::_Default_ranged_hash,
69 __detail::_Prime_rehash_policy, _Tr>;
94 template<
class _Key,
class _Tp,
110 typedef typename _Hashtable::hasher
hasher;
140 const hasher& __hf =
hasher(),
143 : _M_h(__n, __hf, __eql, __a)
159 template<
typename _InputIterator>
162 const hasher& __hf =
hasher(),
165 : _M_h(__f, __l, __n, __hf, __eql, __a)
189 const allocator_type& __a)
190 : _M_h(__umap._M_h, __a)
199 const allocator_type& __a)
200 : _M_h(
std::
move(__umap._M_h), __a)
216 const hasher& __hf =
hasher(),
219 : _M_h(__l, __n, __hf, __eql, __a)
252 {
return _M_h.get_allocator(); }
259 {
return _M_h.empty(); }
264 {
return _M_h.size(); }
269 {
return _M_h.max_size(); }
279 {
return _M_h.begin(); }
288 {
return _M_h.begin(); }
292 {
return _M_h.begin(); }
301 {
return _M_h.end(); }
310 {
return _M_h.end(); }
314 {
return _M_h.end(); }
338 template<
typename... _Args>
341 {
return _M_h.emplace(std::forward<_Args>(__args)...); }
368 template<
typename... _Args>
371 {
return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
393 {
return _M_h.insert(__x); }
395 template<
typename _Pair,
typename =
typename
396 std::enable_if<std::is_constructible<
value_type,
397 _Pair&&>::value>::type>
400 {
return _M_h.insert(std::forward<_Pair>(__x)); }
426 insert(const_iterator __hint,
const value_type& __x)
427 {
return _M_h.insert(__hint, __x); }
429 template<
typename _Pair,
typename =
typename
430 std::enable_if<std::is_constructible<
value_type,
431 _Pair&&>::value>::type>
433 insert(const_iterator __hint, _Pair&& __x)
434 {
return _M_h.insert(__hint, std::forward<_Pair>(__x)); }
446 template<
typename _InputIterator>
448 insert(_InputIterator __first, _InputIterator __last)
449 { _M_h.insert(__first, __last); }
460 { _M_h.insert(__l); }
478 {
return _M_h.erase(__position); }
483 {
return _M_h.erase(__it); }
500 {
return _M_h.erase(__x); }
517 erase(const_iterator __first, const_iterator __last)
518 {
return _M_h.erase(__first, __last); }
541 noexcept( noexcept(_M_h.swap(__x._M_h)) )
542 { _M_h.swap(__x._M_h); }
550 {
return _M_h.hash_function(); }
556 {
return _M_h.key_eq(); }
574 {
return _M_h.find(__x); }
577 find(
const key_type& __x)
const
578 {
return _M_h.find(__x); }
592 {
return _M_h.count(__x); }
605 {
return _M_h.equal_range(__x); }
609 {
return _M_h.equal_range(__x); }
627 {
return _M_h[__k]; }
643 at(
const key_type& __k)
644 {
return _M_h.at(__k); }
647 at(
const key_type& __k)
const
648 {
return _M_h.at(__k); }
656 {
return _M_h.bucket_count(); }
661 {
return _M_h.max_bucket_count(); }
669 bucket_size(size_type __n)
const
670 {
return _M_h.bucket_size(__n); }
678 bucket(
const key_type& __key)
const
679 {
return _M_h.bucket(__key); }
689 {
return _M_h.begin(__n); }
700 {
return _M_h.begin(__n); }
704 {
return _M_h.cbegin(__n); }
715 {
return _M_h.end(__n); }
726 {
return _M_h.end(__n); }
730 {
return _M_h.cend(__n); }
738 {
return _M_h.load_factor(); }
744 {
return _M_h.max_load_factor(); }
752 { _M_h.max_load_factor(__z); }
763 { _M_h.rehash(__n); }
774 { _M_h.reserve(__n); }
776 template<
typename _Key1,
typename _Tp1,
typename _Hash1,
typename _Pred1,
806 template<
class _Key,
class _Tp,
807 class _Hash = hash<_Key>,
822 typedef typename _Hashtable::hasher
hasher;
852 const hasher& __hf =
hasher(),
855 : _M_h(__n, __hf, __eql, __a)
871 template<
typename _InputIterator>
874 const hasher& __hf =
hasher(),
877 : _M_h(__f, __l, __n, __hf, __eql, __a)
901 const allocator_type& __a)
902 : _M_h(__ummap._M_h, __a)
911 const allocator_type& __a)
912 : _M_h(
std::
move(__ummap._M_h), __a)
928 const hasher& __hf =
hasher(),
931 : _M_h(__l, __n, __hf, __eql, __a)
964 {
return _M_h.get_allocator(); }
971 {
return _M_h.empty(); }
976 {
return _M_h.size(); }
981 {
return _M_h.max_size(); }
991 {
return _M_h.begin(); }
1000 {
return _M_h.begin(); }
1004 {
return _M_h.begin(); }
1013 {
return _M_h.end(); }
1022 {
return _M_h.end(); }
1026 {
return _M_h.end(); }
1046 template<
typename... _Args>
1049 {
return _M_h.emplace(std::forward<_Args>(__args)...); }
1072 template<
typename... _Args>
1075 {
return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
1089 {
return _M_h.insert(__x); }
1091 template<
typename _Pair,
typename =
typename
1092 std::enable_if<std::is_constructible<
value_type,
1093 _Pair&&>::value>::type>
1096 {
return _M_h.insert(std::forward<_Pair>(__x)); }
1120 insert(const_iterator __hint,
const value_type& __x)
1121 {
return _M_h.insert(__hint, __x); }
1123 template<
typename _Pair,
typename =
typename
1124 std::enable_if<std::is_constructible<
value_type,
1125 _Pair&&>::value>::type>
1128 {
return _M_h.insert(__hint, std::forward<_Pair>(__x)); }
1140 template<
typename _InputIterator>
1142 insert(_InputIterator __first, _InputIterator __last)
1143 { _M_h.insert(__first, __last); }
1155 { _M_h.insert(__l); }
1173 {
return _M_h.erase(__position); }
1178 {
return _M_h.erase(__it); }
1194 {
return _M_h.erase(__x); }
1212 erase(const_iterator __first, const_iterator __last)
1213 {
return _M_h.erase(__first, __last); }
1237 noexcept( noexcept(_M_h.swap(__x._M_h)) )
1238 { _M_h.swap(__x._M_h); }
1246 {
return _M_h.hash_function(); }
1252 {
return _M_h.key_eq(); }
1270 {
return _M_h.find(__x); }
1274 {
return _M_h.find(__x); }
1284 {
return _M_h.count(__x); }
1295 {
return _M_h.equal_range(__x); }
1299 {
return _M_h.equal_range(__x); }
1307 {
return _M_h.bucket_count(); }
1312 {
return _M_h.max_bucket_count(); }
1320 bucket_size(size_type __n)
const
1321 {
return _M_h.bucket_size(__n); }
1329 bucket(
const key_type& __key)
const
1330 {
return _M_h.bucket(__key); }
1340 {
return _M_h.begin(__n); }
1349 const_local_iterator
1351 {
return _M_h.begin(__n); }
1353 const_local_iterator
1355 {
return _M_h.cbegin(__n); }
1366 {
return _M_h.end(__n); }
1375 const_local_iterator
1377 {
return _M_h.end(__n); }
1379 const_local_iterator
1381 {
return _M_h.cend(__n); }
1389 {
return _M_h.load_factor(); }
1395 {
return _M_h.max_load_factor(); }
1403 { _M_h.max_load_factor(__z); }
1414 { _M_h.rehash(__n); }
1425 { _M_h.reserve(__n); }
1427 template<
typename _Key1,
typename _Tp1,
typename _Hash1,
typename _Pred1,
1431 _Hash1, _Pred1, _Alloc1>&,
1433 _Hash1, _Pred1, _Alloc1>&);
1436 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
1438 swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1439 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1442 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
1444 swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1445 unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1448 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
1450 operator==(
const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1451 const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1452 {
return __x._M_h._M_equal(__y._M_h); }
1454 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
1456 operator!=(
const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1457 const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1458 {
return !(__x == __y); }
1460 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
1462 operator==(
const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1463 const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1464 {
return __x._M_h._M_equal(__y._M_h); }
1466 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
1468 operator!=(
const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1469 const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1470 {
return !(__x == __y); }
1472 _GLIBCXX_END_NAMESPACE_CONTAINER
unordered_multimap(const allocator_type &__a)
Creates an unordered_multimap with no elements.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
key_equal key_eq() const
Returns the key comparison object with which the unordered_map was constructed.
key_equal key_eq() const
Returns the key comparison object with which the unordered_multimap was constructed.
_Hashtable::const_reference const_reference
Iterator-related typedefs.
iterator insert(const_iterator __hint, _Pair &&__x)
Inserts a std::pair into the unordered_multimap.
_Hashtable::hasher hasher
Public typedefs.
size_type bucket_count() const noexcept
Returns the number of buckets of the unordered_multimap.
std::pair< iterator, bool > emplace(_Args &&...__args)
Attempts to build and insert a std::pair into the unordered_map.
iterator emplace_hint(const_iterator __pos, _Args &&...__args)
Attempts to build and insert a std::pair into the unordered_map.
_Hashtable::difference_type difference_type
Iterator-related typedefs.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
_Hashtable::reference reference
Iterator-related typedefs.
_Hashtable::const_pointer const_pointer
Iterator-related typedefs.
iterator insert(const_iterator __hint, const value_type &__x)
Inserts a std::pair into the unordered_multimap.
void insert(_InputIterator __first, _InputIterator __last)
A template function that attempts to insert a range of elements.
unordered_map(const allocator_type &__a)
Creates an unordered_map with no elements.
const_local_iterator end(size_type __n) const
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
iterator begin() noexcept
iterator emplace(_Args &&...__args)
Attempts to build and insert a std::pair into the unordered_multimap.
unordered_multimap & operator=(initializer_list< value_type > __l)
Unordered_multimap list assignment operator.
_Hashtable::const_iterator const_iterator
Iterator-related typedefs.
_Hashtable::iterator iterator
Iterator-related typedefs.
_Hashtable::mapped_type mapped_type
Public typedefs.
size_type size() const noexcept
Returns the size of the unordered_map.
A standard container composed of equivalent keys (possibly containing multiple of each key value) tha...
allocator_type get_allocator() const noexcept
Returns the allocator object with which the unordered_map was constructed.
_Hashtable::key_type key_type
Public typedefs.
void reserve(size_type __n)
Prepare the unordered_map for a specified number of elements.
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_map.
_Hashtable::pointer pointer
Iterator-related typedefs.
const_iterator end() const noexcept
bool empty() const noexcept
Returns true if the unordered_multimap is empty.
local_iterator end(size_type __n)
Returns a read/write iterator pointing to one past the last bucket elements.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert a std::pair into the unordered_map.
hasher hash_function() const
Returns the hash functor object with which the unordered_map was constructed.
const_iterator cend() const noexcept
_Hashtable::value_type value_type
Public typedefs.
size_type count(const key_type &__x) const
Finds the number of elements.
_Hashtable::pointer pointer
Iterator-related typedefs.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the unordered_map.
void max_load_factor(float __z)
Change the unordered_map maximum load factor.
_Hashtable::const_pointer const_pointer
Iterator-related typedefs.
iterator insert(const value_type &__x)
Inserts a std::pair into the unordered_multimap.
Default ranged hash function H. In principle it should be a function object composed from objects of ...
const_iterator cend() const noexcept
iterator find(const key_type &__x)
Tries to locate an element in an unordered_map.
iterator erase(const_iterator __first, const_iterator __last)
Erases a [__first,__last) range of elements from an unordered_multimap.
iterator find(const key_type &__x)
Tries to locate an element in an unordered_multimap.
A standard container composed of unique keys (containing at most one of each key value) that associat...
hasher hash_function() const
Returns the hash functor object with which the unordered_multimap was constructed.
mapped_type & operator[](const key_type &__k)
Subscript ( [] ) access to unordered_map data.
_Hashtable::const_reference const_reference
Iterator-related typedefs.
const_iterator cbegin() const noexcept
_Hashtable::local_iterator local_iterator
Iterator-related typedefs.
void swap(unordered_map &__x) noexcept(noexcept(_M_h.swap(__x._M_h)))
Swaps data with another unordered_map.
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.
iterator insert(const_iterator __hint, const value_type &__x)
Attempts to insert a std::pair into the unordered_map.
void reserve(size_type __n)
Prepare the unordered_multimap for a specified number of elements.
local_iterator begin(size_type __n)
Returns a read/write iterator pointing to the first bucket element.
const_local_iterator cbegin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
const_iterator begin() const noexcept
ISO C++ entities toplevel namespace is std.
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...
const_local_iterator end(size_type __n) const
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
_Hashtable::iterator iterator
Iterator-related typedefs.
_Hashtable::allocator_type allocator_type
Public typedefs.
_Hashtable::key_equal key_equal
Public typedefs.
const mapped_type & at(const key_type &__k) const
Access to unordered_map data.
size_type max_size() const noexcept
Returns the maximum size of the unordered_map.
const_iterator find(const key_type &__x) const
Tries to locate an element in an unordered_map.
const_local_iterator cbegin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
iterator erase(const_iterator __position)
Erases an element from an unordered_multimap.
const_iterator cbegin() const noexcept
bool empty() const noexcept
Returns true if the unordered_map is empty.
The standard allocator, as per [20.4].
float load_factor() const noexcept
Returns the average number of elements per bucket.
One of the comparison functors.
_Hashtable::difference_type difference_type
Iterator-related typedefs.
size_type max_bucket_count() const noexcept
Returns the maximum number of buckets of the unordered_multimap.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
void insert(_InputIterator __first, _InputIterator __last)
A template function that attempts to insert a range of elements.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the unordered_multimap.
unordered_multimap & operator=(const unordered_multimap &)=default
Copy assignment operator.
local_iterator end(size_type __n)
Returns a read/write iterator pointing to one past the last bucket elements.
const_iterator end() const noexcept
unordered_multimap(_InputIterator __f, _InputIterator __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 a range.
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.
unordered_map(_InputIterator __f, _InputIterator __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 a range.
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.
iterator erase(iterator __it)
Erases an element from an unordered_map.
iterator emplace_hint(const_iterator __pos, _Args &&...__args)
Attempts to build and insert a std::pair into the unordered_multimap.
const_local_iterator begin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
const_iterator find(const key_type &__x) const
Tries to locate an element in an unordered_multimap.
_Hashtable::hasher hasher
Public typedefs.
local_iterator begin(size_type __n)
Returns a read/write iterator pointing to the first bucket element.
void swap(unordered_multimap &__x) noexcept(noexcept(_M_h.swap(__x._M_h)))
Swaps data with another unordered_multimap.
unordered_multimap(size_type __n=10, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type())
Default constructor creates no elements.
const_local_iterator begin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
_Hashtable::const_iterator const_iterator
Iterator-related typedefs.
_Hashtable::size_type size_type
Iterator-related typedefs.
_Hashtable::size_type size_type
Iterator-related typedefs.
iterator erase(const_iterator __position)
Erases an element from an unordered_map.
size_type bucket_count() const noexcept
Returns the number of buckets of the unordered_map.
void rehash(size_type __n)
May rehash 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.
_Hashtable::const_local_iterator const_local_iterator
Iterator-related typedefs.
Default value for rehash policy. Bucket size is (usually) the smallest prime that keeps the load fact...
const_iterator begin() const noexcept
std::pair< iterator, bool > insert(_Pair &&__x)
Attempts to insert a std::pair into the unordered_map.
unordered_map(size_type __n=10, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type())
Default constructor creates no elements.
iterator insert(_Pair &&__x)
Inserts a std::pair into the unordered_multimap.
Node const_iterators, used to iterate through all the hashtable.
Primary class template hash.
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_map & operator=(const unordered_map &)=default
Copy assignment operator.
size_type max_size() const noexcept
Returns the maximum size of the unordered_multimap.
allocator_type get_allocator() const noexcept
Returns the allocator object with which the unordered_multimap was constructed.
size_type size() const noexcept
Returns the size of the unordered_multimap.
_Hashtable::mapped_type mapped_type
Public typedefs.
_Hashtable::allocator_type allocator_type
Public typedefs.
void rehash(size_type __n)
May rehash the unordered_multimap.
_Hashtable::key_equal key_equal
Public typedefs.
iterator insert(const_iterator __hint, _Pair &&__x)
Attempts to insert a std::pair into the unordered_map.
iterator erase(iterator __it)
Erases an element from an unordered_multimap.
iterator begin() noexcept
_Hashtable::const_local_iterator const_local_iterator
Iterator-related typedefs.
Struct holding two objects of arbitrary type.
void swap(_Tp &, _Tp &) noexcept(__and_< is_nothrow_move_constructible< _Tp >, is_nothrow_move_assignable< _Tp >>::value)
Swaps two values.
void max_load_factor(float __z)
Change the unordered_multimap maximum load factor.
_Hashtable::value_type value_type
Public typedefs.
unordered_map & operator=(initializer_list< value_type > __l)
Unordered_map list assignment operator.
mapped_type & at(const key_type &__k)
Access to unordered_map data.
const_local_iterator cend(size_type __n) const
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
_Hashtable::key_type key_type
Public typedefs.
Node iterators, used to iterate through all the hashtable.
mapped_type & operator[](key_type &&__k)
Subscript ( [] ) access to unordered_map data.
_Hashtable::local_iterator local_iterator
Iterator-related typedefs.
Default range hashing function: use division to fold a large number into the range [0...
_Hashtable::reference reference
Iterator-related typedefs.
size_type max_bucket_count() const noexcept
Returns the maximum number of buckets of the unordered_map.