Namespaces
Variants

std::unordered_multimap

From cppreference.com
 
 
 
 
Defined in header <unordered_map>
template<
    class Key,
    class T,
    class Hash = std::hash<Key>,
    class KeyEqual = std::equal_to<Key>,
    class Allocator = std::allocator<std::pair<const Key, T>>
> class unordered_multimap;
(1) (since C++11)
namespace pmr {
    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>>>;
}
(2) (since C++17)

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_multimaps), 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 std::unordered_multimap::equal_range.

std::unordered_multimap meets the requirements of Container, AllocatorAwareContainer, UnorderedAssociativeContainer.

All member functions of std::unordered_multimap are constexpr: it is possible to create and use std::unordered_multimap objects in the evaluation of a constant expression.

However, defining a constexpr std::unordered_multimap variable is generally an error, because constant evaluation requires any dynamically allocated storage to be released in the same evaluation, which is usually not the case with std::unordered_multimap's initializer.

(since C++26)

Template parameters