CARVIEW |
Select Language
HTTP/1.1 200 OK
Server: nginx
Date: Sat, 19 Jul 2025 14:09:12 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
ETag: W/"bed7-qbkM4/PZCqIS18i8NKLe0XHll1M"
Content-Encoding: gzip
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.
In the reference for the unordered_multimap member functions, these same names (Key, T, Hash, Pred and Alloc) are assumed for the template parameters.
Reference
C library:
- <cassert> (assert.h)
- <cctype> (ctype.h)
- <cerrno> (errno.h)
-
<cfenv> (fenv.h)C++11
- <cfloat> (float.h)
-
<cinttypes> (inttypes.h)C++11
- <ciso646> (iso646.h)
- <climits> (limits.h)
- <clocale> (locale.h)
- <cmath> (math.h)
- <csetjmp> (setjmp.h)
- <csignal> (signal.h)
- <cstdarg> (stdarg.h)
-
<cstdbool> (stdbool.h)C++11
- <cstddef> (stddef.h)
-
<cstdint> (stdint.h)C++11
- <cstdio> (stdio.h)
- <cstdlib> (stdlib.h)
- <cstring> (string.h)
-
<ctgmath> (tgmath.h)C++11
- <ctime> (time.h)
-
<cuchar> (uchar.h)C++11
- <cwchar> (wchar.h)
- <cwctype> (wctype.h)
Containers:
-
<array>C++11
- <deque>
-
<forward_list>C++11
- <list>
- <map>
- <queue>
- <set>
- <stack>
-
<unordered_map>C++11
-
<unordered_set>C++11
- <vector>
-
Input/Output:
Multi-threading:
-
<atomic>C++11
-
<condition_variable>C++11
-
<future>C++11
-
<mutex>C++11
-
<thread>C++11
-
Other:
- <algorithm>
- <bitset>
-
<chrono>C++11
-
<codecvt>C++11
- <complex>
- <exception>
- <functional>
-
<initializer_list>C++11
- <iterator>
- <limits>
- <locale>
- <memory>
- <new>
- <numeric>
-
<random>C++11
-
<ratio>C++11
-
<regex>C++11
- <stdexcept>
- <string>
-
<system_error>C++11
-
<tuple>C++11
-
<type_traits>C++11
-
<typeindex>C++11
- <typeinfo>
- <utility>
- <valarray>
<unordered_map>
-
unordered_mapC++11
-
unordered_multimapC++11
unordered_multimap
-
unordered_multimap::~unordered_multimapC++11
-
unordered_multimap::unordered_multimapC++11
member functions
-
unordered_multimap::beginC++11
-
unordered_multimap::bucketC++11
-
unordered_multimap::bucket_countC++11
-
unordered_multimap::bucket_sizeC++11
-
unordered_multimap::cbeginC++11
-
unordered_multimap::cendC++11
-
unordered_multimap::clearC++11
-
unordered_multimap::countC++11
-
unordered_multimap::emplaceC++11
-
unordered_multimap::emplace_hintC++11
-
unordered_multimap::emptyC++11
-
unordered_multimap::endC++11
-
unordered_multimap::equal_rangeC++11
-
unordered_multimap::eraseC++11
-
unordered_multimap::findC++11
-
unordered_multimap::get_allocatorC++11
-
unordered_multimap::hash_functionC++11
-
unordered_multimap::insertC++11
-
unordered_multimap::key_eqC++11
-
unordered_multimap::load_factorC++11
-
unordered_multimap::max_bucket_countC++11
-
unordered_multimap::max_load_factorC++11
-
unordered_multimap::max_sizeC++11
-
unordered_multimap::operator=C++11
-
unordered_multimap::rehashC++11
-
unordered_multimap::reserveC++11
-
unordered_multimap::sizeC++11
-
unordered_multimap::swapC++11
-
non-member overloads
- Reference
- <unordered_map>
- unordered_multimap
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
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 type | definition | notes |
---|---|---|
key_type | the first template parameter (Key) | |
mapped_type | the second template parameter (T) | |
value_type | pair<const key_type,mapped_type> | |
hasher | the third template parameter (Hash) | defaults to: hash<key_type> |
key_equal | the fourth template parameter (Pred) | defaults to: equal_to<key_type> |
allocator_type | the fifth template parameter (Alloc) | defaults to: allocator<value_type> |
reference | Alloc::reference | |
const_reference | Alloc::const_reference | |
pointer | Alloc::pointer | for the default allocator: value_type* |
const_pointer | Alloc::const_pointer | for the default allocator: const value_type* |
iterator | a forward iterator to value_type | convertible to const_iterator |
const_iterator | a forward iterator to const value_type | |
local_iterator | a forward iterator to value_type | convertible to const_local_iterator |
const_local_iterator | a forward iterator to const value_type | |
size_type | an unsigned integral type | usually the same as size_t |
difference_type | a signed integral type | usually the same as ptrdiff_t |
member type | definition | notes |
---|---|---|
key_type | the first template parameter (Key) | |
mapped_type | the second template parameter (T) | |
value_type | pair<const key_type,mapped_type> | |
hasher | the third template parameter (Hash) | defaults to: hash<key_type> |
key_equal | the fourth template parameter (Pred) | defaults to: equal_to<key_type> |
allocator_type | the fifth template parameter (Alloc) | defaults to: allocator<value_type> |
reference | value_type& | |
const_reference | const value_type& | |
pointer | allocator_traits<Alloc>::pointer | for the default allocator: value_type* |
const_pointer | allocator_traits<Alloc>::const_pointer | for the default allocator: const value_type* |
iterator | a forward iterator to value_type | convertible to const_iterator |
const_iterator | a forward iterator to const value_type | |
local_iterator | a forward iterator to value_type | convertible to const_local_iterator |
const_local_iterator | a forward iterator to const value_type | |
size_type | an unsigned integral type | usually the same as size_t |
difference_type | a signed integral type | usually the same as ptrdiff_t |
Member functions
- (constructor)
- Construct unordered_multimap (public member function)
- (destructor)
- Destroy unordered multimap (public member function)
- operator=
- Assign content (public member function)
Capacity
- empty
- Test whether container is empty (public member function)
- size
- Return container size (public member function)
- max_size
- Return maximum size (public member function)
Iterators
- begin
- Return iterator to beginning (public member type)
- end
- Return iterator to end (public member type)
- cbegin
- Return const_iterator to beginning (public member function)
- cend
- Return const_iterator to end (public member function)
Element lookup
- find
- Get iterator to element (public member function)
- count
- Count elements with a specific key (public member function)
- equal_range
- Get range of elements with specific key (public member function)
Modifiers
- emplace
- Construct and insert element (public member function)
- emplace_hint
- Construct and insert element with hint (public member function)
- insert
- Insert elements (public member function)
- erase
- Erase elements (public member function)
- clear
- Clear content (public member function)
- swap
- Swap content (public member function)
Buckets
- bucket_count
- Return number of buckets (public member function)
- max_bucket_count
- Return maximum number of buckets (public member function)
- bucket_size
- Return bucket_size (public member type)
- bucket
- Locate element's bucket (public member function)
Hash policy
- load_factor
- Return load factor (public member function)
- max_load_factor
- Get or set maximum load factor (public member function)
- rehash
- Set number of buckets (public member function)
- reserve
- Request a capacity change (public member function)
Observers
- hash_function
- Get hash function (public member type)
- key_eq
- Get key equivalence predicate (public member type)
- get_allocator
- Get allocator (public member function)
Non-member function overloads
- operators (unordered_multimap)
- Relational operators for unordered_multimap (function template)
- swap (unordered_multimap)
- Exchanges contents of two unordered_multimap containers (function template)
Home page | Privacy policy
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us