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;
143 const hasher& __hf =
hasher(),
146 : _M_h(__n, __hf, __eql, __a)
162 template<
typename _InputIterator>
165 const hasher& __hf =
hasher(),
168 : _M_h(__first, __last, __n, __hf, __eql, __a)
192 const allocator_type& __a)
193 : _M_h(__umap._M_h, __a)
202 const allocator_type& __a)
203 : _M_h(std::move(__umap._M_h), __a)
219 const hasher& __hf =
hasher(),
222 : _M_h(__l, __n, __hf, __eql, __a)
230 const allocator_type& __a)
234 template<
typename _InputIterator>
237 const allocator_type& __a)
241 template<
typename _InputIterator>
243 size_type __n,
const hasher& __hf,
244 const allocator_type& __a)
250 const allocator_type& __a)
255 size_type __n,
const hasher& __hf,
256 const allocator_type& __a)
290 {
return _M_h.get_allocator(); }
297 {
return _M_h.empty(); }
302 {
return _M_h.size(); }
307 {
return _M_h.max_size(); }
317 {
return _M_h.begin(); }
326 {
return _M_h.begin(); }
330 {
return _M_h.begin(); }
339 {
return _M_h.end(); }
348 {
return _M_h.end(); }
352 {
return _M_h.end(); }
377 template<
typename... _Args>
380 {
return _M_h.emplace(std::forward<_Args>(__args)...); }
408 template<
typename... _Args>
411 {
return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
433 {
return _M_h.insert(__x); }
435 template<
typename _Pair,
typename =
typename 436 std::enable_if<std::is_constructible<
value_type,
437 _Pair&&>::value>::type>
440 {
return _M_h.insert(std::forward<_Pair>(__x)); }
466 insert(const_iterator __hint,
const value_type& __x)
467 {
return _M_h.insert(__hint, __x); }
469 template<
typename _Pair,
typename =
typename 470 std::enable_if<std::is_constructible<
value_type,
471 _Pair&&>::value>::type>
473 insert(const_iterator __hint, _Pair&& __x)
474 {
return _M_h.insert(__hint, std::forward<_Pair>(__x)); }
486 template<
typename _InputIterator>
488 insert(_InputIterator __first, _InputIterator __last)
489 { _M_h.insert(__first, __last); }
500 { _M_h.insert(__l); }
518 {
return _M_h.erase(__position); }
523 {
return _M_h.erase(__position); }
540 {
return _M_h.erase(__x); }
557 erase(const_iterator __first, const_iterator __last)
558 {
return _M_h.erase(__first, __last); }
582 noexcept( noexcept(_M_h.swap(__x._M_h)) )
583 { _M_h.swap(__x._M_h); }
591 {
return _M_h.hash_function(); }
597 {
return _M_h.key_eq(); }
615 {
return _M_h.find(__x); }
618 find(
const key_type& __x)
const 619 {
return _M_h.find(__x); }
633 {
return _M_h.count(__x); }
646 {
return _M_h.equal_range(__x); }
650 {
return _M_h.equal_range(__x); }
668 {
return _M_h[__k]; }
672 {
return _M_h[std::move(__k)]; }
684 at(
const key_type& __k)
685 {
return _M_h.at(__k); }
688 at(
const key_type& __k)
const 689 {
return _M_h.at(__k); }
697 {
return _M_h.bucket_count(); }
702 {
return _M_h.max_bucket_count(); }
710 bucket_size(size_type __n)
const 711 {
return _M_h.bucket_size(__n); }
719 bucket(
const key_type& __key)
const 720 {
return _M_h.bucket(__key); }
730 {
return _M_h.begin(__n); }
741 {
return _M_h.begin(__n); }
745 {
return _M_h.cbegin(__n); }
756 {
return _M_h.end(__n); }
767 {
return _M_h.end(__n); }
771 {
return _M_h.cend(__n); }
779 {
return _M_h.load_factor(); }
785 {
return _M_h.max_load_factor(); }
793 { _M_h.max_load_factor(__z); }
804 { _M_h.rehash(__n); }
815 { _M_h.reserve(__n); }
817 template<
typename _Key1,
typename _Tp1,
typename _Hash1,
typename _Pred1,
847 template<
class _Key,
class _Tp,
863 typedef typename _Hashtable::hasher
hasher;
896 const hasher& __hf =
hasher(),
899 : _M_h(__n, __hf, __eql, __a)
915 template<
typename _InputIterator>
918 const hasher& __hf =
hasher(),
921 : _M_h(__first, __last, __n, __hf, __eql, __a)
945 const allocator_type& __a)
946 : _M_h(__ummap._M_h, __a)
955 const allocator_type& __a)
956 : _M_h(std::move(__ummap._M_h), __a)
972 const hasher& __hf =
hasher(),
975 : _M_h(__l, __n, __hf, __eql, __a)
983 const allocator_type& __a)
987 template<
typename _InputIterator>
990 const allocator_type& __a)
994 template<
typename _InputIterator>
996 size_type __n,
const hasher& __hf,
997 const allocator_type& __a)
1003 const allocator_type& __a)
1008 size_type __n,
const hasher& __hf,
1009 const allocator_type& __a)
1043 {
return _M_h.get_allocator(); }
1050 {
return _M_h.empty(); }
1055 {
return _M_h.size(); }
1060 {
return _M_h.max_size(); }
1070 {
return _M_h.begin(); }
1079 {
return _M_h.begin(); }
1083 {
return _M_h.begin(); }
1092 {
return _M_h.end(); }
1101 {
return _M_h.end(); }
1105 {
return _M_h.end(); }
1125 template<
typename... _Args>
1128 {
return _M_h.emplace(std::forward<_Args>(__args)...); }
1152 template<
typename... _Args>
1155 {
return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
1169 {
return _M_h.insert(__x); }
1171 template<
typename _Pair,
typename =
typename 1172 std::enable_if<std::is_constructible<
value_type,
1173 _Pair&&>::value>::type>
1176 {
return _M_h.insert(std::forward<_Pair>(__x)); }
1200 insert(const_iterator __hint,
const value_type& __x)
1201 {
return _M_h.insert(__hint, __x); }
1203 template<
typename _Pair,
typename =
typename 1204 std::enable_if<std::is_constructible<
value_type,
1205 _Pair&&>::value>::type>
1208 {
return _M_h.insert(__hint, std::forward<_Pair>(__x)); }
1220 template<
typename _InputIterator>
1222 insert(_InputIterator __first, _InputIterator __last)
1223 { _M_h.insert(__first, __last); }
1235 { _M_h.insert(__l); }
1253 {
return _M_h.erase(__position); }
1258 {
return _M_h.erase(__position); }
1274 {
return _M_h.erase(__x); }
1292 erase(const_iterator __first, const_iterator __last)
1293 {
return _M_h.erase(__first, __last); }
1317 noexcept( noexcept(_M_h.swap(__x._M_h)) )
1318 { _M_h.swap(__x._M_h); }
1326 {
return _M_h.hash_function(); }
1332 {
return _M_h.key_eq(); }
1350 {
return _M_h.find(__x); }
1354 {
return _M_h.find(__x); }
1364 {
return _M_h.count(__x); }
1375 {
return _M_h.equal_range(__x); }
1379 {
return _M_h.equal_range(__x); }
1387 {
return _M_h.bucket_count(); }
1392 {
return _M_h.max_bucket_count(); }
1400 bucket_size(size_type __n)
const 1401 {
return _M_h.bucket_size(__n); }
1409 bucket(
const key_type& __key)
const 1410 {
return _M_h.bucket(__key); }
1420 {
return _M_h.begin(__n); }
1429 const_local_iterator
1431 {
return _M_h.begin(__n); }
1433 const_local_iterator
1435 {
return _M_h.cbegin(__n); }
1446 {
return _M_h.end(__n); }
1455 const_local_iterator
1457 {
return _M_h.end(__n); }
1459 const_local_iterator
1461 {
return _M_h.cend(__n); }
1469 {
return _M_h.load_factor(); }
1475 {
return _M_h.max_load_factor(); }
1483 { _M_h.max_load_factor(__z); }
1494 { _M_h.rehash(__n); }
1505 { _M_h.reserve(__n); }
1507 template<
typename _Key1,
typename _Tp1,
typename _Hash1,
typename _Pred1,
1511 _Hash1, _Pred1, _Alloc1>&,
1513 _Hash1, _Pred1, _Alloc1>&);
1516 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
1522 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
1528 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
1532 {
return __x._M_h._M_equal(__y._M_h); }
1534 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
1538 {
return !(__x == __y); }
1540 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
1544 {
return __x._M_h._M_equal(__y._M_h); }
1546 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
1550 {
return !(__x == __y); }
1552 _GLIBCXX_END_NAMESPACE_CONTAINER
void insert(_InputIterator __first, _InputIterator __last)
A template function that attempts to insert a range of elements.
local_iterator end(size_type __n)
Returns a read/write iterator pointing to one past the last bucket elements.
_Hashtable::local_iterator local_iterator
Iterator-related typedefs.
_Hashtable::iterator iterator
Iterator-related typedefs.
unordered_multimap(_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_multimap 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.
float load_factor() const noexcept
Returns the average number of elements per bucket.
A standard container composed of unique keys (containing at most one of each key value) that associat...
iterator insert(const_iterator __hint, const value_type &__x)
Attempts to insert a std::pair into the unordered_map.
_Hashtable::const_local_iterator const_local_iterator
Iterator-related typedefs.
_Hashtable::mapped_type mapped_type
Public typedefs.
_Hashtable::key_type key_type
Public typedefs.
const_local_iterator begin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the unordered_multimap.
_Hashtable::key_type key_type
Public typedefs.
size_type bucket_count() const noexcept
Returns the number of buckets of the unordered_multimap.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
iterator erase(iterator __position)
Erases an element from an unordered_multimap.
Default ranged hash function H. In principle it should be a function object composed from objects of ...
void rehash(size_type __n)
May rehash the unordered_map.
iterator erase(const_iterator __first, const_iterator __last)
Erases a [__first,__last) range of elements from an unordered_multimap.
_Hashtable::size_type size_type
Iterator-related typedefs.
_Hashtable::const_iterator const_iterator
Iterator-related typedefs.
_Hashtable::key_equal key_equal
Public typedefs.
std::pair< iterator, bool > insert(_Pair &&__x)
Attempts to insert a std::pair into the unordered_map.
const_iterator find(const key_type &__x) const
Tries to locate an element in an unordered_multimap.
iterator begin() noexcept
iterator find(const key_type &__x)
Tries to locate an element in an unordered_multimap.
unordered_map & operator=(const unordered_map &)=default
Copy assignment operator.
iterator erase(const_iterator __first, const_iterator __last)
Erases a [__first,__last) range of elements from an unordered_map.
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.
_Hashtable::const_pointer const_pointer
Iterator-related typedefs.
const_iterator end() const noexcept
const_iterator begin() const noexcept
size_type erase(const key_type &__x)
Erases elements according to the provided key.
void reserve(size_type __n)
Prepare the unordered_multimap for a specified number of elements.
_Hashtable::const_reference const_reference
Iterator-related typedefs.
unordered_map(const allocator_type &__a)
Creates an unordered_map with no elements.
The standard allocator, as per [20.4].
unordered_map(_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_map from a range.
size_type count(const key_type &__x) const
Finds the number of elements.
_Hashtable::allocator_type allocator_type
Public typedefs.
unordered_multimap(const allocator_type &__a)
Creates an unordered_multimap with no elements.
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()=default
Default constructor.
_Hashtable::value_type value_type
Public typedefs.
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.
iterator insert(const value_type &__x)
Inserts a std::pair into the unordered_multimap.
iterator insert(const_iterator __hint, _Pair &&__x)
Attempts to insert a std::pair into the unordered_map.
size_type max_bucket_count() const noexcept
Returns the maximum number of buckets of the unordered_multimap.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
unordered_map(size_type __n, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type())
Default constructor creates no elements.
size_type max_size() const noexcept
Returns the maximum size of the unordered_multimap.
const_iterator cbegin() const noexcept
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
const_iterator end() const noexcept
std::pair< iterator, bool > emplace(_Args &&...__args)
Attempts to build and insert a std::pair into the unordered_map.
local_iterator end(size_type __n)
Returns a read/write iterator pointing to one past the last bucket elements.
size_type size() const noexcept
Returns the size of the unordered_map.
iterator insert(const_iterator __hint, const value_type &__x)
Inserts a std::pair into the unordered_multimap.
size_type max_size() const noexcept
Returns the maximum size of the unordered_map.
const mapped_type & at(const key_type &__k) const
Access to unordered_map data.
_Hashtable::allocator_type allocator_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_multimap(size_type __n, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type())
Default constructor creates no elements.
allocator_type get_allocator() const noexcept
Returns the allocator object with which the unordered_map was constructed.
iterator erase(const_iterator __position)
Erases an element from an unordered_multimap.
const_iterator begin() const noexcept
void max_load_factor(float __z)
Change the unordered_multimap maximum load factor.
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...
Primary class template hash.
_Hashtable::const_iterator const_iterator
Iterator-related typedefs.
mapped_type & operator[](const key_type &__k)
Subscript ( [] ) access to unordered_map data.
Default value for rehash policy. Bucket size is (usually) the smallest prime that keeps the load fact...
One of the comparison functors.
size_type max_bucket_count() const noexcept
Returns the maximum number of buckets of the unordered_map.
void swap(unordered_multimap &__x) noexcept(noexcept(_M_h.swap(__x._M_h)))
Swaps data with another unordered_multimap.
mapped_type & at(const key_type &__k)
Access to unordered_map data.
_Hashtable::reference reference
Iterator-related typedefs.
void reserve(size_type __n)
Prepare the unordered_map for a specified 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.
_Hashtable::hasher hasher
Public typedefs.
_Hashtable::difference_type difference_type
Iterator-related typedefs.
const_local_iterator cbegin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
_Hashtable::key_equal key_equal
Public typedefs.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the unordered_map.
local_iterator begin(size_type __n)
Returns a read/write iterator pointing to the first bucket element.
allocator_type get_allocator() const noexcept
Returns the allocator object with which the unordered_multimap was constructed.
const_local_iterator cbegin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
_Hashtable::reference reference
Iterator-related typedefs.
_Hashtable::local_iterator local_iterator
Iterator-related typedefs.
void rehash(size_type __n)
May rehash the unordered_multimap.
const_local_iterator begin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
_Hashtable::const_local_iterator const_local_iterator
Iterator-related typedefs.
_Hashtable::const_pointer const_pointer
Iterator-related typedefs.
_Hashtable::iterator iterator
Iterator-related typedefs.
A standard container composed of equivalent keys (possibly containing multiple of each key value) tha...
void insert(_InputIterator __first, _InputIterator __last)
A template function that attempts to insert a range of elements.
iterator emplace_hint(const_iterator __pos, _Args &&...__args)
Attempts to build and insert a std::pair into the unordered_map.
mapped_type & operator[](key_type &&__k)
Subscript ( [] ) access to unordered_map data.
const_iterator cbegin() const noexcept
unordered_map & operator=(initializer_list< value_type > __l)
Unordered_map list assignment operator.
_Hashtable::value_type value_type
Public typedefs.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert a std::pair into the unordered_map.
_Hashtable::pointer pointer
Iterator-related typedefs.
hasher hash_function() const
Returns the hash functor object with which the unordered_multimap was constructed.
local_iterator begin(size_type __n)
Returns a read/write iterator pointing to the first bucket element.
iterator find(const key_type &__x)
Tries to locate an element in an unordered_map.
iterator emplace(_Args &&...__args)
Attempts to build and insert a std::pair into the unordered_multimap.
void max_load_factor(float __z)
Change the unordered_map maximum load factor.
Default range hashing function: use division to fold a large number into the range [0...
size_type bucket_count() const noexcept
Returns the number of buckets of the unordered_map.
size_type size() const noexcept
Returns the size of the unordered_multimap.
Struct holding two objects of arbitrary type.
_Hashtable::const_reference const_reference
Iterator-related typedefs.
float load_factor() const noexcept
Returns the average number of elements per bucket.
iterator erase(const_iterator __position)
Erases an element from an unordered_map.
const_iterator cend() const noexcept
iterator begin() noexcept
key_equal key_eq() const
Returns the key comparison object with which the unordered_map was constructed.
unordered_multimap & operator=(initializer_list< value_type > __l)
Unordered_multimap list assignment operator.
key_equal key_eq() const
Returns the key comparison object with which the unordered_multimap was constructed.
const_iterator find(const key_type &__x) const
Tries to locate an element in an unordered_map.
_Hashtable::mapped_type mapped_type
Public typedefs.
_Hashtable::pointer pointer
Iterator-related typedefs.
void swap(unordered_map &__x) noexcept(noexcept(_M_h.swap(__x._M_h)))
Swaps data with another unordered_map.
const_local_iterator cend(size_type __n) const
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
ISO C++ entities toplevel namespace is std.
const_iterator cend() const noexcept
iterator insert(const_iterator __hint, _Pair &&__x)
Inserts a std::pair into the unordered_multimap.
bool empty() const noexcept
Returns true if the unordered_map is empty.
iterator insert(_Pair &&__x)
Inserts a std::pair into the unordered_multimap.
hasher hash_function() const
Returns the hash functor object with which the unordered_map was constructed.
size_type count(const key_type &__x) const
Finds the number of elements.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
_Hashtable::size_type size_type
Iterator-related typedefs.
iterator erase(iterator __position)
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.
_Hashtable::difference_type difference_type
Iterator-related typedefs.
bool empty() const noexcept
Returns true if the unordered_multimap is empty.