30#ifndef _UNORDERED_MAP_H
31#define _UNORDERED_MAP_H
33namespace 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,
94 template<
class _Key,
class _Tp,
108 typedef typename _Hashtable::value_type value_type;
109 typedef typename _Hashtable::mapped_type mapped_type;
110 typedef typename _Hashtable::hasher hasher;
111 typedef typename _Hashtable::key_equal key_equal;
112 typedef typename _Hashtable::allocator_type allocator_type;
118 typedef typename _Hashtable::const_pointer const_pointer;
119 typedef typename _Hashtable::reference reference;
120 typedef typename _Hashtable::const_reference const_reference;
121 typedef typename _Hashtable::iterator iterator;
122 typedef typename _Hashtable::const_iterator const_iterator;
123 typedef typename _Hashtable::local_iterator local_iterator;
124 typedef typename _Hashtable::const_local_iterator const_local_iterator;
125 typedef typename _Hashtable::size_type size_type;
126 typedef typename _Hashtable::difference_type difference_type;
143 const hasher&
__hf = hasher(),
144 const key_equal&
__eql = key_equal(),
145 const allocator_type& __a = allocator_type())
162 template<
typename _InputIterator>
165 const hasher&
__hf = hasher(),
166 const key_equal&
__eql = key_equal(),
167 const allocator_type& __a = allocator_type())
168 : _M_h(__first, __last, __n,
__hf,
__eql, __a)
192 const allocator_type& __a)
202 const allocator_type& __a)
203 : _M_h(
std::move(__umap._M_h), __a)
219 const hasher&
__hf = hasher(),
220 const key_equal&
__eql = key_equal(),
221 const allocator_type& __a = allocator_type())
230 const allocator_type& __a)
234 template<
typename _InputIterator>
237 const allocator_type& __a)
238 :
unordered_map(__first, __last, __n, hasher(), key_equal(), __a)
241 template<
typename _InputIterator>
243 size_type __n,
const hasher& __hf,
244 const allocator_type& __a)
245 :
unordered_map(__first, __last, __n, __hf, key_equal(), __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>
408 template<
typename...
_Args>
414#if __cplusplus > 201402L
415#define __cpp_lib_unordered_map_try_emplace 201411
438 template <
typename...
_Args>
446 std::forward_as_tuple(
__k),
447 std::forward_as_tuple(
456 template <
typename... _Args>
458 try_emplace(
key_type&& __k, _Args&&... __args)
460 iterator __i =
find(__k);
464 std::forward_as_tuple(std::move(__k)),
465 std::forward_as_tuple(
501 template <
typename... _Args>
503 try_emplace(const_iterator __hint,
const key_type& __k,
506 iterator __i =
find(__k);
509 std::forward_as_tuple(__k),
510 std::forward_as_tuple(
516 template <
typename... _Args>
518 try_emplace(const_iterator __hint,
key_type&& __k, _Args&&... __args)
520 iterator __i =
find(__k);
523 std::forward_as_tuple(std::move(__k)),
524 std::forward_as_tuple(
550 {
return _M_h.insert(__x); }
552 template<
typename _Pair,
typename =
typename
554 _Pair&&>::value>::type>
584 {
return _M_h.insert(
__hint, __x); }
586 template<
typename _Pair,
typename =
typename
588 _Pair&&>::value>::type>
603 template<
typename _InputIterator>
606 { _M_h.insert(__first, __last); }
617 { _M_h.insert(
__l); }
620#if __cplusplus > 201402L
621#define __cpp_lib_unordered_map_insertion 201411
642 template <
typename _Obj>
650 std::forward_as_tuple(
__k),
660 template <
typename _Obj>
662 insert_or_assign(
key_type&& __k, _Obj&& __obj)
664 iterator __i =
find(__k);
668 std::forward_as_tuple(std::move(__k)),
703 template <
typename _Obj>
705 insert_or_assign(const_iterator __hint,
const key_type& __k,
708 iterator __i =
find(__k);
712 std::forward_as_tuple(__k),
713 std::forward_as_tuple(
721 template <
typename _Obj>
723 insert_or_assign(const_iterator __hint,
key_type&& __k, _Obj&& __obj)
725 iterator __i =
find(__k);
729 std::forward_as_tuple(std::move(__k)),
730 std::forward_as_tuple(
776 {
return _M_h.erase(__x); }
793 erase(const_iterator __first, const_iterator __last)
794 {
return _M_h.erase(__first, __last); }
818 noexcept(
noexcept(_M_h.swap(__x._M_h)) )
819 { _M_h.swap(__x._M_h); }
827 {
return _M_h.hash_function(); }
833 {
return _M_h.key_eq(); }
851 {
return _M_h.find(__x); }
855 {
return _M_h.find(__x); }
869 {
return _M_h.count(__x); }
882 {
return _M_h.equal_range(__x); }
886 {
return _M_h.equal_range(__x); }
904 {
return _M_h[
__k]; }
908 {
return _M_h[std::move(
__k)]; }
921 {
return _M_h.at(
__k); }
925 {
return _M_h.at(
__k); }
933 {
return _M_h.bucket_count(); }
938 {
return _M_h.max_bucket_count(); }
946 bucket_size(size_type __n)
const
947 {
return _M_h.bucket_size(__n); }
956 {
return _M_h.bucket(__key); }
966 {
return _M_h.begin(__n); }
977 {
return _M_h.begin(__n); }
980 cbegin(size_type __n)
const
981 {
return _M_h.cbegin(__n); }
992 {
return _M_h.end(__n); }
1001 const_local_iterator
1003 {
return _M_h.end(__n); }
1005 const_local_iterator
1006 cend(size_type __n)
const
1007 {
return _M_h.cend(__n); }
1015 {
return _M_h.load_factor(); }
1021 {
return _M_h.max_load_factor(); }
1029 { _M_h.max_load_factor(
__z); }
1040 { _M_h.rehash(__n); }
1051 { _M_h.reserve(__n); }
1083 template<
class _Key,
class _Tp,
1084 class _Hash = hash<_Key>,
1097 typedef typename _Hashtable::value_type value_type;
1098 typedef typename _Hashtable::mapped_type mapped_type;
1099 typedef typename _Hashtable::hasher hasher;
1100 typedef typename _Hashtable::key_equal key_equal;
1101 typedef typename _Hashtable::allocator_type allocator_type;
1107 typedef typename _Hashtable::const_pointer const_pointer;
1108 typedef typename _Hashtable::reference reference;
1109 typedef typename _Hashtable::const_reference const_reference;
1110 typedef typename _Hashtable::iterator iterator;
1111 typedef typename _Hashtable::const_iterator const_iterator;
1112 typedef typename _Hashtable::local_iterator local_iterator;
1113 typedef typename _Hashtable::const_local_iterator const_local_iterator;
1114 typedef typename _Hashtable::size_type size_type;
1115 typedef typename _Hashtable::difference_type difference_type;
1132 const hasher&
__hf = hasher(),
1133 const key_equal&
__eql = key_equal(),
1134 const allocator_type& __a = allocator_type())
1151 template<
typename _InputIterator>
1154 const hasher&
__hf = hasher(),
1155 const key_equal&
__eql = key_equal(),
1156 const allocator_type& __a = allocator_type())
1157 : _M_h(__first, __last, __n,
__hf,
__eql, __a)
1181 const allocator_type& __a)
1191 const allocator_type& __a)
1192 : _M_h(
std::move(__ummap._M_h), __a)
1208 const hasher&
__hf = hasher(),
1209 const key_equal&
__eql = key_equal(),
1210 const allocator_type& __a = allocator_type())
1219 const allocator_type& __a)
1223 template<
typename _InputIterator>
1226 const allocator_type& __a)
1230 template<
typename _InputIterator>
1232 size_type __n,
const hasher& __hf,
1233 const allocator_type& __a)
1239 const allocator_type& __a)
1244 size_type __n,
const hasher& __hf,
1245 const allocator_type& __a)
1279 {
return _M_h.get_allocator(); }
1286 {
return _M_h.empty(); }
1291 {
return _M_h.size(); }
1296 {
return _M_h.max_size(); }
1306 {
return _M_h.begin(); }
1315 {
return _M_h.begin(); }
1319 {
return _M_h.begin(); }
1328 {
return _M_h.end(); }
1337 {
return _M_h.end(); }
1341 {
return _M_h.end(); }
1361 template<
typename... _Args>
1388 template<
typename...
_Args>
1405 {
return _M_h.insert(__x); }
1407 template<
typename _Pair,
typename =
typename
1409 _Pair&&>::value>::type>
1437 {
return _M_h.insert(
__hint, __x); }
1439 template<
typename _Pair,
typename =
typename
1441 _Pair&&>::value>::type>
1456 template<
typename _InputIterator>
1459 { _M_h.insert(__first, __last); }
1471 { _M_h.insert(
__l); }
1510 {
return _M_h.erase(__x); }
1528 erase(const_iterator __first, const_iterator __last)
1529 {
return _M_h.erase(__first, __last); }
1553 noexcept(
noexcept(_M_h.swap(__x._M_h)) )
1554 { _M_h.swap(__x._M_h); }
1562 {
return _M_h.hash_function(); }
1568 {
return _M_h.key_eq(); }
1586 {
return _M_h.find(__x); }
1590 {
return _M_h.find(__x); }
1600 {
return _M_h.count(__x); }
1611 {
return _M_h.equal_range(__x); }
1615 {
return _M_h.equal_range(__x); }
1623 {
return _M_h.bucket_count(); }
1628 {
return _M_h.max_bucket_count(); }
1636 bucket_size(size_type __n)
const
1637 {
return _M_h.bucket_size(__n); }
1645 bucket(
const key_type& __key)
const
1646 {
return _M_h.bucket(__key); }
1656 {
return _M_h.begin(__n); }
1665 const_local_iterator
1667 {
return _M_h.begin(__n); }
1669 const_local_iterator
1670 cbegin(size_type __n)
const
1671 {
return _M_h.cbegin(__n); }
1682 {
return _M_h.end(__n); }
1691 const_local_iterator
1693 {
return _M_h.end(__n); }
1695 const_local_iterator
1696 cend(size_type __n)
const
1697 {
return _M_h.cend(__n); }
1705 {
return _M_h.load_factor(); }
1711 {
return _M_h.max_load_factor(); }
1719 { _M_h.max_load_factor(
__z); }
1730 { _M_h.rehash(__n); }
1741 { _M_h.reserve(__n); }
1752 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
1754 swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1755 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1756 noexcept(
noexcept(__x.swap(__y)))
1759 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
1761 swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1762 unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1763 noexcept(
noexcept(__x.swap(__y)))
1766 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
1768 operator==(
const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1769 const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1770 {
return __x._M_h._M_equal(__y._M_h); }
1772 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
1774 operator!=(
const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1775 const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1776 {
return !(__x == __y); }
1778 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
1780 operator==(
const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1781 const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1782 {
return __x._M_h._M_equal(__y._M_h); }
1784 template<
class _Key,
class _Tp,
class _Hash,
class _Pred,
class _Alloc>
1786 operator!=(
const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1787 const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1788 {
return !(__x == __y); }
1790_GLIBCXX_END_NAMESPACE_CONTAINER
constexpr piecewise_construct_t piecewise_construct
piecewise_construct
ISO C++ entities toplevel namespace is std.
Default range hashing function: use division to fold a large number into the range [0,...
Default ranged hash function H. In principle it should be a function object composed from objects of ...
Default value for rehash policy. Bucket size is (usually) the smallest prime that keeps the load fact...
A standard container composed of unique keys (containing at most one of each key value) that associat...
void max_load_factor(float __z)
Change the unordered_map maximum load factor.
void insert(_InputIterator __first, _InputIterator __last)
A template function that attempts to insert a range of elements.
allocator_type get_allocator() const noexcept
Returns the allocator object with which the unordered_map was constructed.
unordered_map & operator=(initializer_list< value_type > __l)
Unordered_map list assignment operator.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the unordered_map.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
mapped_type & at(const key_type &__k)
Access to unordered_map data.
iterator erase(const_iterator __first, const_iterator __last)
Erases a [__first,__last) range of elements from an unordered_map.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert a std::pair into the unordered_map.
void reserve(size_type __n)
Prepare the unordered_map for a specified number of elements.
iterator insert(const_iterator __hint, const value_type &__x)
Attempts to insert a std::pair into the unordered_map.
unordered_map(const unordered_map &)=default
Copy constructor.
size_type count(const key_type &__x) const
Finds the number of elements.
bool empty() const noexcept
Returns true if the unordered_map is empty.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
unordered_map(unordered_map &&)=default
Move constructor.
const_local_iterator end(size_type __n) const
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
size_type max_size() const noexcept
Returns the maximum size of the unordered_map.
const_iterator end() const noexcept
unordered_map()=default
Default constructor.
unordered_map & operator=(unordered_map &&)=default
Move assignment operator.
const_local_iterator begin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
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.
std::pair< iterator, bool > emplace(_Args &&... __args)
Attempts to build and insert a std::pair into the unordered_map.
size_type size() const noexcept
Returns the size of the unordered_map.
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.
mapped_type & operator[](const key_type &__k)
Subscript ( [] ) access to unordered_map data.
const_iterator begin() const noexcept
key_equal key_eq() const
Returns the key comparison object with which the unordered_map was constructed.
local_iterator end(size_type __n)
Returns a read/write iterator pointing to one past the last bucket elements.
_Hashtable::pointer pointer
Iterator-related typedefs.
unordered_map(const allocator_type &__a)
Creates an unordered_map with no elements.
_Hashtable::key_type key_type
Public typedefs.
size_type bucket_count() const noexcept
Returns the number of buckets of the unordered_map.
iterator begin() noexcept
hasher hash_function() const
Returns the hash functor object with which the unordered_map was constructed.
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 find(const key_type &__x)
Tries to locate an element in an unordered_map.
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.
void swap(unordered_map &__x) noexcept(noexcept(_M_h.swap(__x._M_h)))
Swaps data with another unordered_map.
local_iterator begin(size_type __n)
Returns a read/write iterator pointing to the first bucket element.
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.
unordered_map & operator=(const unordered_map &)=default
Copy assignment operator.
size_type max_bucket_count() const noexcept
Returns the maximum number of buckets of the unordered_map.
iterator emplace_hint(const_iterator __pos, _Args &&... __args)
Attempts to build and insert a std::pair into the unordered_map.
void rehash(size_type __n)
May rehash the unordered_map.
A standard container composed of equivalent keys (possibly containing multiple of each key value) tha...
float load_factor() const noexcept
Returns the average number of elements per bucket.
const_iterator end() const noexcept
size_type erase(const key_type &__x)
Erases elements according to the provided key.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
size_type bucket_count() const noexcept
Returns the number of buckets of the unordered_multimap.
size_type max_bucket_count() const noexcept
Returns the maximum number of buckets of the unordered_multimap.
iterator begin() noexcept
const_iterator begin() const noexcept
hasher hash_function() const
Returns the hash functor object with which the unordered_multimap was constructed.
unordered_multimap & operator=(const unordered_multimap &)=default
Copy assignment operator.
key_equal key_eq() const
Returns the key comparison object with which the unordered_multimap was constructed.
size_type count(const key_type &__x) const
Finds the number of elements.
local_iterator end(size_type __n)
Returns a read/write iterator pointing to one past the last bucket elements.
void insert(_InputIterator __first, _InputIterator __last)
A template function that attempts to insert a range of elements.
unordered_multimap & operator=(initializer_list< value_type > __l)
Unordered_multimap list assignment operator.
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.
iterator emplace(_Args &&... __args)
Attempts to build and insert a std::pair into the unordered_multimap.
iterator erase(const_iterator __position)
Erases an element from an unordered_multimap.
local_iterator begin(size_type __n)
Returns a read/write iterator pointing to the first bucket element.
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_multimap()=default
Default constructor.
iterator insert(const value_type &__x)
Inserts a std::pair into the unordered_multimap.
unordered_multimap & operator=(unordered_multimap &&)=default
Move assignment operator.
void reserve(size_type __n)
Prepare the unordered_multimap for a specified number of elements.
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.
iterator find(const key_type &__x)
Tries to locate an element in an unordered_multimap.
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(const_iterator __first, const_iterator __last)
Erases a [__first,__last) range of elements from an unordered_multimap.
const_local_iterator end(size_type __n) const
Returns a read-only (constant) iterator pointing to one past the last bucket elements.
_Hashtable::pointer pointer
Iterator-related typedefs.
const_local_iterator begin(size_type __n) const
Returns a read-only (constant) iterator pointing to the first bucket element.
unordered_multimap(unordered_multimap &&)=default
Move constructor.
unordered_multimap(const allocator_type &__a)
Creates an unordered_multimap with no elements.
void swap(unordered_multimap &__x) noexcept(noexcept(_M_h.swap(__x._M_h)))
Swaps data with another unordered_multimap.
void rehash(size_type __n)
May rehash the unordered_multimap.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the unordered_multimap.
size_type max_size() const noexcept
Returns the maximum size of the unordered_multimap.
bool empty() const noexcept
Returns true if the unordered_multimap is empty.
_Hashtable::key_type key_type
Public typedefs.
iterator insert(const_iterator __hint, const value_type &__x)
Inserts a std::pair into the unordered_multimap.
size_type size() const noexcept
Returns the size of the unordered_multimap.
unordered_multimap(const unordered_multimap &)=default
Copy constructor.
iterator emplace_hint(const_iterator __pos, _Args &&... __args)
Attempts to build and insert a std::pair into the unordered_multimap.
allocator_type get_allocator() const noexcept
Returns the allocator object with which the unordered_multimap was constructed.
void max_load_factor(float __z)
Change the unordered_multimap maximum load factor.