std::unordered_multimap
std::unordered_multimap
<unordered_map>
class Key,
class T,
class Hash = std::hash <Key>,
class KeyEqual = std::equal_to <Key>,
class Allocator = std::allocator <std::pair <const Key, T>>
template<
class Key,
class T,
class Hash = std::hash <Key>,
class Pred = std::equal_to <Key>
> using unordered_multimap =
std::unordered_multimap<Key, T, Hash, Pred,
std::pmr::polymorphic_allocator <std::pair <const Key, T>>>;
std::unordered_multimap
is an unordered associative container that supports equivalent keys (an unordered_multimap may contain multiple copies of each key value) and that associates values of another type with the keys. The unordered_multimap class supports forward iterators. Search, insertion, and removal have average constant-time complexity.
Internally, the elements are not sorted in any particular order, but organized into buckets. Which bucket an element is placed into depends entirely on the hash of its key. This allows fast access to individual elements, since once the hash is computed, it refers to the exact bucket the element is placed into.
The iteration order of this container is not required to be stable (so, for example, std::equal cannot be used to compare two std::unordered_multimap
s), except that every group of elements whose keys compare equivalent (compare equal with key_eq() as the comparator) forms a contiguous subrange in the iteration order, also accessible with equal_range() .
std::unordered_multimap
meets the requirements of Container, AllocatorAwareContainer, UnorderedAssociativeContainer.
std::unordered_multimap
are constexpr: it is possible to create and use std::unordered_multimap
objects in the evaluation of a constant expression.However, std::unordered_multimap
objects generally cannot be constexpr, because any dynamically allocated storage must be released in the same evaluation of constant expression.
Contents
[edit] Template parameters
Reason: Add descriptions of the template parameters.
[edit] Member types
local_iterator
An iterator type whose category, value, difference, pointer andreference types are the same as
iterator
. This iteratorcan be used to iterate through a single bucket but not across buckets[edit]
const_local_iterator
An iterator type whose category, value, difference, pointer andreference types are the same as
const_iterator
. This iteratorcan be used to iterate through a single bucket but not across buckets[edit]
[edit] Member functions
Iterators
Capacity
Modifiers
Lookup
Bucket interface
Hash policy
(public member function) [edit]
(public member function) [edit]
Observers
[edit] Non-member functions
(function template) [edit]
Deduction guides
(since C++17)[edit] Notes
Feature-test macro | Value | Std | Feature |
---|---|---|---|
__cpp_lib_containers_ranges |
202202L |
(C++23) | Ranges construction and insertion for containers |
__cpp_lib_constexpr_unordered_map |
202502L |
(C++26) | constexpr std::unordered_multimap
|
[edit] Example
Reason: no example
[edit] Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 2050 | C++11 | the definitions of reference , const_reference , pointer and const_pointer were based on allocator_type
|
based on value_type andstd::allocator_traits |
[edit] See also
(class template) [edit]