Reorder unordered_map reference docs to match the order found in the synopsis

This commit is contained in:
Christian Mazakas
2022-02-14 16:23:55 -08:00
parent fe55012007
commit 1ee2eaf5e9

View File

@ -212,8 +212,8 @@ template<class Key, class T, class Hash, class Pred, class Alloc>
|_Key_
|`Key` must be https://en.cppreference.com/w/cpp/named_req/Erasable[Erasable^] from the container (i.e. `allocator_traits` can destroy it).
|_Mapped_
|`Mapped` must be https://en.cppreference.com/w/cpp/named_req/Erasable[Erasable^] from the container (i.e. `allocator_traits` can destroy it).
|_T_
|`T` must be https://en.cppreference.com/w/cpp/named_req/Erasable[Erasable^] from the container (i.e. `allocator_traits` can destroy it).
|_Hash_
|A unary function object type that acts a hash function for a `Key`. It takes a single argument of type `Key` and returns a value of type `std::size_t`.
@ -221,7 +221,7 @@ template<class Key, class T, class Hash, class Pred, class Alloc>
|_Pred_
|A binary function object that implements an equivalence relation on values of type `Key`. A binary function object that induces an equivalence relation on values of type `Key`. It takes two arguments of type `Key` and returns a value of type bool.
|_Alloc_
|_Allocator_
|An allocator whose value type is the same as the container's value type.
|===
@ -358,13 +358,13 @@ Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type`
==== Bucket Count Constructor
```c++
explicit unordered_map(size_type n,
hasher const& hf = hasher(),
key_equal const& eq = key_equal(),
allocator_type const& a = allocator_type());
const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
```
Constructs an empty container with at least `n` buckets, using `hf` as the hash
function, `eq` as the key equality predicate, `a` as the allocator and a maximum
function, `eql` as the key equality predicate, `a` as the allocator and a maximum
load factor of `1.0`.
Postconditions:: `size() == 0`
@ -373,6 +373,23 @@ Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type`
---
==== Iterator Range Constructor
[source,c++,subs="+quotes"]
----
template<class InputIterator>
unordered_map(InputIterator f, InputIterator l,
size_type n = _implementation-defined_,
const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
----
Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eql` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it.
Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].
---
==== Copy Constructor
```c++
unordered_map(unordered_map const& other);
@ -430,6 +447,22 @@ Requires:: `value_type` is move insertable.
---
==== Initializer List Constructor
[source,c++,subs="+quotes"]
----
unordered_map(initializer_list<value_type> il,
size_type n = _implementation-defined_
const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
----
Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eql` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `il` into it.
Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].
---
==== Bucket Count Constructor with Allocator
```c++
unordered_map(size_type n, allocator_type const& a);
@ -454,48 +487,11 @@ Requires:: `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/D
---
==== Initializer List Constructor
[source,c++,subs="quotes,macros"]
----
unordered_map(initializer_list++<++value_type++>++ il,
size_type n = _implementation-defined_,
hasher const& hf = hasher(),
key_equal const& eq = key_equal(),
allocator_type const& a = allocator_type());
----
Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eq` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `il` into it.
Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].
---
==== Iterator Range Constructor
[source,c++,subs="quotes,macros"]
----
template++<++typename InputIterator++>++
unordered_map(InputIterator f,
InputIterator l,
size_type n = _implementation-defined_,
hasher const& hf = hasher(),
key_equal const& eq = key_equal(),
allocator_type const& a = allocator_type());
----
Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eq` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it.
Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].
---
==== Iterator Range Constructor with Bucket Count and Allocator
[source,c++,subs="quotes,macros"]
[source,c++,subs="+quotes"]
----
template++<++typename InputIterator++>++
unordered_map(InputIterator f,
InputIterator l,
size_type n,
allocator_type const& a);
template<class InputIterator>
unordered_map(InputIterator f, InputIterator l, size_type n, const allocator_type& a);
----
Constructs an empty container with at least `n` buckets, using `a` as the allocator, with the default hash function and key equality predicate and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it.
@ -505,14 +501,11 @@ Requires:: `hasher`, `key_equal` need to be https://en.cppreference.com/w/cpp/na
---
==== Iterator Range Constructor with Bucket Count and Hasher
[source,c++,subs="quotes,macros"]
[source,c++,subs="+quotes"]
----
template++<++typename InputIterator++>++
unordered_map(InputIterator f,
InputIterator l,
size_type n,
hasher const& hf,
allocator_type const& a);
template<class InputIterator>
unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf,
const allocator_type& a);
----
Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `a` as the allocator, with the default key equality predicate and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it.
@ -548,7 +541,10 @@ Requires:: `value_type` is copy constructible
==== Move Assignment
```c++
unordered_map& operator=(unordered_map&& other);
unordered_map& operator=(unordered_map&& other)
noexcept(boost::allocator_traits<Allocator>::is_always_equal::value &&
boost::is_nothrow_move_assignable_v<Hash> &&
boost::is_nothrow_move_assignable_v<Pred>);
```
The move assignment operator.
@ -569,12 +565,51 @@ Assign from values in initializer list. All existing elements are either overwri
Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^] into the container and https://en.cppreference.com/w/cpp/named_req/CopyAssignable[CopyAssignable^].
=== Iterators
==== begin
```c++
iterator begin() noexcept;
const_iterator begin() const noexcept;
```
Returns:: An iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container.
---
==== end
```c++
iterator end() noexcept;
const_iterator end() const noexcept;
```
Returns:: An iterator which refers to the past-the-end value for the container.
---
==== cbegin
```c++
const_iterator cbegin() const noexcept;
```
Returns:: A `const_iterator` referring to the first element of the container, or if the container is empty the past-the-end value for the container.
---
==== cend
```c++
const_iterator cend() const noexcept;
```
Returns:: A `const_iterator` which refers to the past-the-end value for the container.
---
=== Size and Capacity
==== empty
```c++
bool empty() const;
bool empty() const noexcept;
```
Returns:: `size() == 0`
@ -584,7 +619,7 @@ Returns:: `size() == 0`
==== size
```c++
size_type size() const;
size_type size() const noexcept;
```
Returns:: `std::distance(begin(), end())`
@ -594,59 +629,18 @@ Returns:: `std::distance(begin(), end())`
==== max_size
```c++
size_type max_size() const;
size_type max_size() const noexcept;
```
Returns:: `size()` of the largest possible container.
---
=== Iterators
==== begin
```c++
iterator begin();
const_iterator begin() const;
```
Returns:: An iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container.
---
==== end
```c++
iterator end();
const_iterator end() const;
```
Returns:: An iterator which refers to the past-the-end value for the container.
---
==== cbegin
```c++
const_iterator cbegin() const;
```
Returns:: A `const_iterator` referring to the first element of the container, or if the container is empty the past-the-end value for the container.
---
==== cend
```c++
const_iterator cend() const;
```
Returns:: A `const_iterator` which refers to the past-the-end value for the container.
---
=== Modifiers
==== emplace
```c++
template<typename... Args>
std::pair<iterator, bool>
emplace(Args&&... args);
template<class... Args> std::pair<iterator, bool> emplace(Args&&... args);
```
Inserts an object, constructed with the arguments `args`, in the container if and only if there is no element in the container with an equivalent key.
@ -667,14 +661,12 @@ Since existing `std::pair` implementations don't support `std::piecewise_constru
==== emplace_hint
```c++
template<typename... Args>
iterator
emplace_hint(const_iterator hint, Args&&... args);
template<class... Args> iterator emplace_hint(const_iterator position, Args&&... args);
```
Inserts an object, constructed with the arguments `args`, in the container if and only if there is no element in the container with an equivalent key.
`hint` is a suggestion to where the element should be inserted.
`position` is a suggestion to where the element should be inserted.
Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `args`.
@ -692,8 +684,7 @@ Since existing `std::pair` implementations don't support `std::piecewise_constru
==== Copy Insert
```c++
std::pair<iterator, bool>
insert(value_type const& obj);
std::pair<iterator, bool> insert(const value_type& obj);
```
Inserts `obj` in the container if and only if there is no element in the container with an equivalent key.
@ -710,8 +701,7 @@ Notes:: Can invalidate iterators, but only if the insert causes the load factor
==== Move Insert
```c++
std::pair<iterator, bool>
insert(value_type&& obj);
std::pair<iterator, bool> insert(value_type&& obj);
```
Inserts `obj` in the container if and only if there is no element in the container with an equivalent key.
@ -728,9 +718,7 @@ Notes:: Can invalidate iterators, but only if the insert causes the load factor
==== Emplace Insert
```c++
template <class P>
std::pair<iterator, bool>
insert(P&& value);
template<class P> std::pair<iterator, bool> insert(P&& obj);
```
Inserts an element into the container by performing `emplace(std::forward<P>(value))`.
@ -741,29 +729,9 @@ Returns:: The bool component of the return type is true if an insert took place.
---
==== Insert with `node_handle`
```c++
insert_return_type
insert(node_type&& nh);
```
If `nh` is empty, has no effect.
Otherwise inserts the element owned by `nh` if and only if there is no element in the container with an equivalent key.
Requires:: `nh` is empty or `nh.get_allocator()` is equal to the container's allocator.
Returns:: If `nh` was empty, returns an `insert_return_type` with: `inserted` equal to `false`, `position` equal to `end()` and `node` empty. Otherwise if there was already an element with an equivalent key, returns an `insert_return_type` with: `inserted` equal to `false`, `position` pointing to a matching element and `node` contains the node from `nh`. Otherwise if the insertion succeeded, returns an `insert_return_type` with: `inserted` equal to `true`, `position` pointing to the newly inserted element and `node` empty.
Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect.
Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. In C++17 this can be used to insert a node extracted from a compatible `unordered_multimap`, but that is not supported yet.
---
==== Copy Insert with Hint
```c++
iterator insert(const_iterator hint, value_type const& obj);
iterator insert(const_iterator hint, const value_type& obj);
```
Inserts `obj` in the container if and only if there is no element in the container with an equivalent key.
@ -801,9 +769,7 @@ Notes:: The standard is fairly vague on the meaning of the hint. But the only pr
==== Emplace Insert with Hint
```c++
template <class P>
std::pair<iterator, bool>
insert(const_iterator hint, P&& value);
template<class P> iterator insert(const_iterator hint, P&& obj);
```
Inserts an element into the container by performing `emplace_hint(hint, std::forward<P>(value))`.
@ -818,6 +784,100 @@ Notes:: The standard is fairly vague on the meaning of the hint. But the only pr
---
==== Insert Iterator Range
```c++
template<class InputIterator> void insert(InputIterator first, InputIterator last);
```
Inserts a range of elements into the container. Elements are inserted if and only if there is no element in the container with an equivalent key.
Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `*first`.
Throws:: When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect.
Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated.
---
==== Insert Initializer List
```c++
void insert(initializer_list<value_type>);
```
Inserts a range of elements into the container. Elements are inserted if and only if there is no element in the container with an equivalent key.
Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `*first`.
Throws:: When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect.
Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated.
---
==== Extract by Iterator
```c++
node_type extract(const_iterator position);
```
Removes the element pointed to by `position`.
Returns:: A `node_type` owning the element.
Notes:: In C++17 a node extracted using this method can be inserted into a compatible `unordered_multimap`, but that is not supported yet.
---
==== Extract by Key
```c++
node_type extract(const key_type& k);
```
Removes an element with key equivalent to `k`.
Returns:: A `node_type` owning the element if found, otherwise an empty `node_type`.
Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`.
Notes:: In C++17 a node extracted using this method can be inserted into a compatible `unordered_multimap`, but that is not supported yet.
---
==== Transparent Extract by Key
```c++
template<class K> node_type extract(K&& k);
```
Removes an element with key equivalent to `k`.
This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
Returns:: A `node_type` owning the element if found, otherwise an empty `node_type`.
Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`.
Notes:: In C++17 a node extracted using this method can be inserted into a compatible `unordered_multimap`, but that is not supported yet.
---
==== Insert with `node_handle`
```c++
insert_return_type insert(node_type&& nh);
```
If `nh` is empty, has no effect.
Otherwise inserts the element owned by `nh` if and only if there is no element in the container with an equivalent key.
Requires:: `nh` is empty or `nh.get_allocator()` is equal to the container's allocator.
Returns:: If `nh` was empty, returns an `insert_return_type` with: `inserted` equal to `false`, `position` equal to `end()` and `node` empty. Otherwise if there was already an element with an equivalent key, returns an `insert_return_type` with: `inserted` equal to `false`, `position` pointing to a matching element and `node` contains the node from `nh`. Otherwise if the insertion succeeded, returns an `insert_return_type` with: `inserted` equal to `true`, `position` pointing to the newly inserted element and `node` empty.
Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect.
Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. In C++17 this can be used to insert a node extracted from a compatible `unordered_multimap`, but that is not supported yet.
---
==== Insert with Hint and `node_handle`
```c++
iterator insert(const_iterator hint, node_type&& nh);
@ -841,84 +901,10 @@ Notes:: The standard is fairly vague on the meaning of the hint. But the only pr
---
==== Insert Iterator Range
```c++
template<typename InputIterator>
void insert(InputIterator first, InputIterator last);
```
Inserts a range of elements into the container. Elements are inserted if and only if there is no element in the container with an equivalent key.
Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `*first`.
Throws:: When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect.
Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated.
---
==== Insert Initializer List
```c++
void insert(initializer_list<value_type> il);
```
Inserts a range of elements into the container. Elements are inserted if and only if there is no element in the container with an equivalent key.
Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `*first`.
Throws:: When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect.
Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated.
---
==== Extract by Iterator
```c++
node_type extract(const_iterator position);
```
Removes the element pointed to by `position`.
Returns:: A `node_type` owning the element.
Notes:: In C++17 a node extracted using this method can be inserted into a compatible `unordered_multimap`, but that is not supported yet.
---
==== Transparent Extract by Key
```c++
template<typename K>
node_type extract(K&& k);
```
Removes an element with key equivalent to `k`.
This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
Returns:: A `node_type` owning the element if found, otherwise an empty `node_type`.
Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`.
Notes:: In C++17 a node extracted using this method can be inserted into a compatible `unordered_multimap`, but that is not supported yet.
---
==== Extract by Key
```c++
node_type extract(key_type const& k);
```
Removes an element with key equivalent to `k`.
Returns:: A `node_type` owning the element if found, otherwise an empty `node_type`.
Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`.
Notes:: In C++17 a node extracted using this method can be inserted into a compatible `unordered_multimap`, but that is not supported yet.
==== Erase by Position
```c++
iterator erase(iterator position);
iterator erase(const_iterator position);
```
@ -932,6 +918,34 @@ Notes:: In older versions this could be inefficient because it had to search thr
---
==== Erase by Key
```c++
size_type erase(const key_type& k);
```
Erase all elements with key equivalent to `k`.
Returns:: The number of elements erased.
Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`.
---
==== Transparent Erase by Key
```c++
template<class K> size_type erase(K&& k);
```
Erase all elements with key equivalent to `k`.
This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
Returns:: The number of elements erased.
Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`.
---
==== Erase Range
```c++
@ -946,35 +960,6 @@ Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. In
---
==== Transparent Erase by Key
```c++
template<typename K>
size_type erase(K&& k);
```
Erase all elements with key equivalent to `k`.
This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
Returns:: The number of elements erased.
Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`.
---
==== Erase by Key
```c++
size_type erase(key_type const& k);
```
Erase all elements with key equivalent to `k`.
Returns:: The number of elements erased.
Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`.
---
==== quick_erase
```c++
void quick_erase(const_iterator position);
@ -1001,6 +986,24 @@ Notes:: This method was implemented because returning an iterator to the next el
---
==== swap
```c++
void swap(unordered_map& other)
noexcept(boost::allocator_traits<Allocator>::is_always_equal::value &&
boost::is_nothrow_swappable_v<Hash> &&
boost::is_nothrow_swappable_v<Pred>);
```
Swaps the contents of the container with the parameter.
If `Allocator::propagate_on_container_swap` is declared and `Allocator::propagate_on_container_swap::value` is `true` then the containers' allocators are swapped. Otherwise, swapping with unequal allocators results in undefined behavior.
Throws:: Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`.
Notes:: The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors.
---
==== clear
```c++
void clear();
@ -1014,25 +1017,10 @@ Throws:: Never throws an exception.
---
==== swap
```c++
void swap(unordered_map& other);
```
Swaps the contents of the container with the parameter.
If `Allocator::propagate_on_container_swap` is declared and `Allocator::propagate_on_container_swap::value` is `true` then the containers' allocators are swapped. Otherwise, swapping with unequal allocators results in undefined behavior.
Throws:: Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`.
Notes:: The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors.
---
==== merge
```c++
template<typename H2, typename P2>
void merge(unordered_map<Key, Mapped, H2, P2, Alloc>& source);
void merge(unordered_map<Key, T, H2, P2, Alloc>& source);
```
Notes:: Does not support merging with a compatible `unordered_multimap` yet.
@ -1042,7 +1030,7 @@ Notes:: Does not support merging with a compatible `unordered_multimap` yet.
==== merge (rvalue reference)
```c++
template<typename H2, typename P2>
void merge(unordered_map<Key, Mapped, H2, P2, Alloc>&& source);
void merge(unordered_map<Key, T, H2, P2, Alloc>&& source);
```
Notes:: Does not support merging with a compatible `unordered_multimap` yet.
@ -1056,6 +1044,8 @@ Notes:: Does not support merging with a compatible `unordered_multimap` yet.
allocator_type get_allocator() const;
```
---
==== hash_function
```
hasher hash_function() const;
@ -1065,6 +1055,7 @@ Returns:: The container's hash function.
---
==== key_eq
```
key_equal key_eq() const;
```
@ -1077,34 +1068,18 @@ Returns:: The container's key equality predicate
==== find
```c++
iterator find(key_type const& k);
const_iterator find(key_type const& k) const;
template<typename K>
iterator
find(K const& k);
template<typename K>
const_iterator
find(K const& k) const;
template<
typename CompatibleKey,
typename CompatibleHash,
typename CompatiblePredicate>
iterator
find(CompatibleKey const& k,
CompatibleHash const& hash,
CompatiblePredicate const& eq);
template<
typename CompatibleKey,
typename CompatibleHash,
typename CompatiblePredicate>
const_iterator
find(CompatibleKey const& k,
CompatibleHash const& hash,
CompatiblePredicate const& eq) const;
iterator find(const key_type& k);
const_iterator find(const key_type& k) const;
template<class K>
iterator find(const K& k);
template<class K>
const_iterator find(const K& k) const;
template<typename CompatibleKey, typename CompatibleHash, typename CompatiblePredicate>
iterator find(CompatibleKey const& k, CompatibleHash const& hash,
CompatiblePredicate const& eq);
template<typename CompatibleKey, typename CompatibleHash, typename CompatiblePredicate>
const_iterator find(CompatibleKey const& k, CompatibleHash const& hash,
CompatiblePredicate const& eq) const;
```
@ -1115,24 +1090,11 @@ The `template <typename K>` overloads only participate in overload resolution if
---
==== contains
```c++
template<typename K>
bool contains(K const& key);
bool contains(key_type const& key) const;
```
Returns:: A boolean indicating whether or not there is an element with key equal to `key` in the container
Notes:: The `template <typename K>` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
---
==== count
```c++
template<typename K>
size_type count(K const& k) const;
size_type count(key_type const& k) const;
size_type count(const key_type& k) const;
template<class K>
size_type count(const K& k) const;
```
Returns:: The number of elements with key equivalent to `k`.
@ -1141,21 +1103,27 @@ Notes:: The `template <typename K>` overload only participates in overload resol
---
==== contains
```c++
bool contains(const key_type& k) const;
template<class K>
bool contains(const K& k) const;
```
Returns:: A boolean indicating whether or not there is an element with key equal to `key` in the container
Notes:: The `template <typename K>` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
---
==== equal_range
```c++
std::pair<iterator, iterator>
equal_range(key_type const& k);
std::pair<const_iterator, const_iterator>
equal_range(key_type const& k) const;
template<typename K>
std::pair<iterator, iterator>
equal_range(K const& k);
template<typename K>
std::pair<const_iterator, const_iterator>
equal_range(K const& k) const;
pair<iterator, iterator> equal_range(const key_type& k);
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
template<class K>
pair<iterator, iterator> equal_range(const K& k);
template<class K>
pair<const_iterator, const_iterator> equal_range(const K& k) const;
```
Returns:: A range containing all elements with key equivalent to `k`. If the container doesn't contain any such elements, returns `std::make_pair(b.end(), b.end())`.
@ -1166,7 +1134,8 @@ Notes:: The `template <typename K>` overloads only participate in overload resol
==== operator++[++++]++
```c++
mapped_type& operator[](key_type const& k);
mapped_type& operator[](const key_type& k);
mapped_type& operator[](key_type&& k);
```
Effects:: If the container does not already contain an elements with a key equivalent to `k`, inserts the value `std::pair<key_type const, mapped_type>(k, mapped_type())`.
@ -1181,8 +1150,8 @@ Notes:: Can invalidate iterators, but only if the insert causes the load factor
==== at
```c++
Mapped& at(key_type const& k);
Mapped const& at(key_type const& k) const;
mapped_type& at(const key_type& k);
const mapped_type& at(const key_type& k) const;
```
Returns:: A reference to `x.second` where `x` is the (unique) element whose key is equivalent to `k`.
@ -1195,7 +1164,7 @@ Throws:: An exception object of type `std::out_of_range` if no such element is p
==== bucket_count
```c++
size_type bucket_count() const;
size_type bucket_count() const noexcept;
```
Returns:: The number of buckets.
@ -1204,7 +1173,7 @@ Returns:: The number of buckets.
==== max_bucket_count
```c++
size_type max_bucket_count() const;
size_type max_bucket_count() const noexcept;
```
Returns:: An upper bound on the number of buckets.
@ -1224,7 +1193,7 @@ Returns:: The number of elements in bucket `n`.
==== bucket
```c++
size_type bucket(key_type const& k) const;
size_type bucket(const key_type& k) const;
```
Returns:: The index of the bucket which would contain an element with key `k`.
@ -1284,7 +1253,7 @@ Returns:: A constant local iterator pointing the 'one past the end' element in t
==== load_factor
```c++
float load_factor() const;
float load_factor() const noexcept;
```
Returns:: The average number of elements per bucket.
@ -1294,7 +1263,7 @@ Returns:: The average number of elements per bucket.
==== max_load_factor
```c++
float max_load_factor() const;
float max_load_factor() const noexcept;
```
Returns:: Returns the current maximum load factor.
@ -1337,14 +1306,9 @@ Throws:: The function has no effect if an exception is thrown, unless it is thro
==== operator==
```c++
template<
typename Key,
typename Mapped,
typename Hash,
typename Pred,
typename Alloc>
bool operator==(unordered_map<Key, Mapped, Hash, Pred, Alloc> const& x,
unordered_map<Key, Mapped, Hash, Pred, Alloc> const& y);
template<class Key, class T, class Hash, class Pred, class Alloc>
bool operator==(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
const unordered_map<Key, T, Hash, Pred, Alloc>& y);
```
Return `true` if `x.size() == y.size()` and for every element in `x`, there is an element in `y` with the same key, with an equal value (using `operator==` to compare the value types).
@ -1355,14 +1319,9 @@ Notes:: The behavior of this function was changed to match the C++11 standard in
==== operator!=
```c++
template<
typename Key,
typename Mapped,
typename Hash,
typename Pred,
typename Alloc>
bool operator!=(unordered_map<Key, Mapped, Hash, Pred, Alloc> const& x,
unordered_map<Key, Mapped, Hash, Pred, Alloc> const& y);
template<class Key, class T, class Hash, class Pred, class Alloc>
bool operator!=(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
const unordered_map<Key, T, Hash, Pred, Alloc>& y);
```
Return `false` if `x.size() == y.size()` and for every element in `x`, there is an element in `y` with the same key, with an equal value (using `operator==` to compare the value types).
@ -1371,10 +1330,10 @@ Notes:: The behavior of this function was changed to match the C++11 standard in
=== Swap
```c++
template<typename Key, typename Mapped, typename Hash, typename Pred,
typename Alloc>
void swap(unordered_map<Key, Mapped, Hash, Pred, Alloc>& x,
unordered_map<Key, Mapped, Hash, Pred, Alloc>& y);
template<class Key, class T, class Hash, class Pred, class Alloc>
void swap(unordered_map<Key, T, Hash, Pred, Alloc>& x,
unordered_map<Key, T, Hash, Pred, Alloc>& y)
noexcept(noexcept(x.swap(y)));
```
Swaps the contents of `x` and `y`.