class template
<unordered_map>

std::unordered_multimap

template < class Key,                                    // unordered_multimap::key_type
           class T,                                      // unordered_multimap::mapped_type
           class Hash = hash<Key>,                       // unordered_multimap::hasher
           class Pred = equal_to<Key>,                   // unordered_multimap::key_equal
           class Alloc = allocator< pair<const Key,T> >  // unordered_multimap::allocator_type
           > class unordered_multimap;
Unordered Multimap
Unordered multimaps are associative containers that store elements formed by the combination of a key value and a mapped value, much like unordered_map containers, but allowing different elements to have equivalent keys.

In an unordered_multimap, the key value is generally used to uniquely identify the element, while the mapped value is an object with the content associated to this key. Types of key and mapped value may differ.

Internally, the elements in the unordered_multimap are not sorted in any particular order with respect to either their key or mapped values, but organized into buckets depending on their hash values to allow for fast access to individual elements directly by their key values (with a constant average time complexity on average).

Elements with equivalent keys are grouped together in the same bucket and in such a way that an iterator (see equal_range) can iterate through all of them.

Iterators in the container are at least forward iterators.

Notice that this container is not defined in its own header, but shares header <unordered_map> with unordered_map.

Container properties

Associative
Elements in associative containers are referenced by their key and not by their absolute position in the container.
Unordered
Unordered containers organize their elements using hash tables that allow for fast access to elements by their key.
Map
Each element associates a key to a mapped value: Keys are meant to identify the elements whose main content is the mapped value.
Multiple equivalent keys
The container can hold multiple elements with equivalent keys.
Allocator-aware
The container uses an allocator object to dynamically handle its storage needs.

Template parameters

Key
Type of the key values. Each element in an unordered_multimap is identified by a key value.
Aliased as member type unordered_multimap::key_type.
T
Type of the mapped value. Each element in an unordered_multimap is used to store some data as its mapped value.
Aliased as member type unordered_multimap::mapped_type. Note that this is not the same as unordered_multimap::value_type (see below).
Hash
A unary function object type that takes an object of type key type as argument and returns a unique value of type size_t based on it. This can either be a class implementing a function call operator or a pointer to a function (see constructor for an example). This defaults to hash<Key>, which returns a hash value with a probability of collision approaching 1.0/std::numeric_limits<size_t>::max().
The unordered_multimap object uses the hash values returned by this function to organize its elements internally, speeding up the process of locating individual elements.
Aliased as member type unordered_multimap::hasher.
Pred
A binary predicate that takes two arguments of the key type and returns a bool. The expression pred(a,b), where pred is an object of this type and a and b are key values, shall return true if a is to be considered equivalent to b. This can either be a class implementing a function call operator or a pointer to a function (see constructor for an example). This defaults to equal_to<Key>, which returns the same as applying the equal-to operator (a==b).
The unordered_multimap object uses this expression to determine whether two element keys are equivalent. This container supports multiple elements with equivalent keys.
Aliased as member type unordered_multimap::key_equal.
Alloc
Type of the allocator object used to define the storage allocation model. By default, the allocator class template is used, which defines the simplest memory allocation model and is value-independent.
Aliased as member type unordered_multimap::allocator_type.

In the reference for the unordered_multimap member functions, these same names (Key, T, Hash, Pred and Alloc) are assumed for the template parameters.

Member types

The following aliases are member types of unordered_multimap. They are widely used as parameter and return types by member functions:

member typedefinitionnotes
key_typethe first template parameter (Key)
mapped_typethe second template parameter (T)
value_typepair<const key_type,mapped_type>
hasherthe third template parameter (Hash)defaults to: hash<key_type>
key_equalthe fourth template parameter (Pred)defaults to: equal_to<key_type>
allocator_typethe fifth template parameter (Alloc)defaults to: allocator<value_type>
referenceAlloc::reference
const_referenceAlloc::const_reference
pointerAlloc::pointerfor the default allocator: value_type*
const_pointerAlloc::const_pointerfor the default allocator: const value_type*
iteratora forward iterator to value_typeconvertible to const_iterator
const_iteratora forward iterator to const value_type
local_iteratora forward iterator to value_typeconvertible to const_local_iterator
const_local_iteratora forward iterator to const value_type
size_typean unsigned integral typeusually the same as size_t
difference_typea signed integral typeusually the same as ptrdiff_t
member typedefinitionnotes
key_typethe first template parameter (Key)
mapped_typethe second template parameter (T)
value_typepair<const key_type,mapped_type>
hasherthe third template parameter (Hash)defaults to: hash<key_type>
key_equalthe fourth template parameter (Pred)defaults to: equal_to<key_type>
allocator_typethe fifth template parameter (Alloc)defaults to: allocator<value_type>
referencevalue_type&
const_referenceconst value_type&
pointerallocator_traits<Alloc>::pointerfor the default allocator: value_type*
const_pointerallocator_traits<Alloc>::const_pointerfor the default allocator: const value_type*
iteratora forward iterator to value_typeconvertible to const_iterator
const_iteratora forward iterator to const value_type
local_iteratora forward iterator to value_typeconvertible to const_local_iterator
const_local_iteratora forward iterator to const value_type
size_typean unsigned integral typeusually the same as size_t
difference_typea signed integral typeusually the same as ptrdiff_t

Member functions


Capacity


Iterators


Element lookup


Modifiers


Buckets


Hash policy


Observers


Non-member function overloads

  • 997351548 2018-02-20
  • 903691547 2018-02-20
  • 9127171546 2018-02-20
  • 2234751545 2018-02-20
  • 1685381544 2018-02-20
  • 911091543 2018-02-20
  • 9281021542 2018-02-20
  • 632231541 2018-02-20
  • 9751491540 2018-02-20
  • 8333621539 2018-02-20
  • 995001538 2018-02-20
  • 6477441537 2018-02-20
  • 511981536 2018-02-19
  • 2072881535 2018-02-19
  • 6024461534 2018-02-19
  • 7594061533 2018-02-19
  • 9311341532 2018-02-19
  • 4928331531 2018-02-19
  • 38561530 2018-02-19
  • 7776611529 2018-02-19