C++ Library - <unordered_map>

Unordered map is dictionary like data structure. It is a sequence of (key, value) pair, where only single value is associated with each unique key. It is often referred as associative array. It enables fast retrieval of individual elements based on their keys. It also implements the direct access operator(subscript operator[]) which allows for direct access of the mapped value using its key value as argument.
Unordered map does not sort its element in any particular order with respect to either their key or mapped values, instead organizes into buckets depending on their hash values to allow for fast access to individual elements directly by their key values.
Unordered map performs better than map while accessing individual elements by their keys. But for range iteration their performance is considerably low.
Below is definition of std::unordered_map from <unordered_map> header file
template < class Key,
           class T,
           class Hash = hash<Key>,
           class Pred = equal_to<Key>,
           class Alloc = allocator< pair<const Key,T> >
           > class unordered_map;

Key − Type of the key.
Key − Type of the key.
T − Type of the mapped values.
T − Type of the mapped values.
Hash − A unary function object type which takes an object of type key type as argument and returns a unique value of type size_t based on it.
Hash − A unary function object type which takes an object of type key type as argument and returns a unique value of type size_t based on it.
Pred − A binary predicate that which two arguments of the key type and returns a bool.
Pred − A binary predicate that which two arguments of the key type and returns a bool.
Alloc − Type of the allocator object.
Alloc − Type of the allocator object.
T may be substituted by any other data type including user-defined type.
Following member types can be used as parameters or return type by member functions.
Below is list of all methods from <unordered_map> header.
Constructs an empty unordered_map with zero elements.
Constructs an unordered_map with copy of each elements present in existing unordered_map.
Constructs an unordered_map with the contents of other using move semantics.
Constructs an unordered_map with as many elements as in range of first to last.
Constructs an unordered_map from initialize list.
Destroys unordered_map object by deallocating it's memory.
Returns a reference to the mapped value associated with key k.
Returns an iterator which refers to the first element of the map.
Returns an iterator pointing to the first element in one of its buckets.
Returns the bucket number where element with key k is located.
Returns the number of buckets in unordered_map container.
Returns the number of elements presents in the nth bucket.
Returns a constant iterator which refers to the first element of the unordered_map.
Returns a constant iterator pointing to the first element in one of its buckets.
Returns a constant iterator which points to past-the-end element of the unordered_map.
Returns a constant iterator which points to past-the-end element in one of its buckets.
Destroys the unordered_map by removing all elements and sets the size of unordered_map to zero.
Returns the number of mapped values associated with key k.
Extends container by inserting new element.
Inserts a new element in unordered_map using hint as a position for element.
Tests whether unordered_map is empty or not.
Returns an iterator which points to past-the-end element in the unordered_map.
Returns an iterator which points to past-the-end element in one of its buckets.
Returns range of elements that matches specific key.
Removes single element of the unordered_map from position.
Removes mapped value associated with key k.
Removes range of element from the the unordered_map.
Finds an element associated with key k.
Returns an allocator associated with unordered_map.
Calculates the hash function object used by the unordered_map container.
Extends container by inserting new element in unordered_map.
Extends container by inserting new element in unordered_map.
Extends conta iner by inserting new element in unordered_map.
Extends unordered_map by inserting new element.
Extends container by inserting new elements in the unordered_map.
Extends map by inserting new element from initializer list.
Returns the function that compares keys for equality.
Returns the current load factor of the unordered_map container.
Returns the maximum number of buckets that the unordered_map container can have.
Returns the current maximum load factor for the unordered_map container.
Assigns new load factor for the unordered_map container.
Returns the maximum number of elements can be held by unordered_map.
Assigns new contents to the unordered_map by replacing old ones and modifies size if necessary.
Move the contents of one unordered_map into another and modifies size if necessary.
Copy elements from initializer list to unordered_map.
If key k matches an element in the container, then method returns a reference to the element.
If key k matches an element in the container, then method returns a reference to the element.
Sets the number of buckets in the container to n or more.
Sets the number of buckets in the container to the most appropriate to contain at least n elements.
Returns the number of elements present in the unordered_map.
Exchanges the content of first unordered_map with another.
Tests whether two unordered_maps are equal or not.
Tests whether two unordered_maps are equal or not.
Exchanges the content of first unordered_map with another.
Unordered_multimap is dictionary like data structure. It is a sequence of (key, value) pair, where different elements can have equivalent keys. Elements with equivalent keys are grouped together in the same bucket and in such a way that an equal_range iterator can iterate through all of them.
Unordered_multimap does not sort its element in any particular order with respect to either their key or mapped values, instead organizes into buckets depending on their hash values to allow for fast access to individual elements directly by their key values.
Below is definition of std::unordered_multimap from <unordered_map> header file
template < class Key, 
           class T,
           class Hash = hash<Key>,
           class Pred = equal_to<Key>,
           class Alloc = allocator< pair<const Key,T> >
           > class unordered_multimap;

Key − Type of the key.
Key − Type of the key.
T − Type of the mapped values.
T − Type of the mapped values.
Hash − A unary function object type which takes an object of type key type as argument and returns a unique value of type size_t based on it.
Hash − A unary function object type which takes an object of type key type as argument and returns a unique value of type size_t based on it.
Pred − A binary predicate that which two arguments of the key type and returns a bool.
Pred − A binary predicate that which two arguments of the key type and returns a bool.
Alloc − Type of the allocator object.
T may be substituted by any other data type including user-defined type.
Alloc − Type of the allocator object.
T may be substituted by any other data type including user-defined type.
Following member types can be used as parameters or return type by member functions.
Below is list of all methods from <unordered_map> header.
Constructs an empty unordered_multimap with zero elements.
Constructs an unordered_multimap with copy of each elements present in existing unordered_multimap.
Constructs an unordered_multimap with the contents of other using move semantics.
Constructs an unordered_multimap with as many elements as in range of first to last.
Constructs an unordered_multimap from initialize list.
Destroys unordered_multimap object by deallocating it's memory.
Returns an iterator which refers to the first element of the unordered_mulitmap.
Returns an iterator pointing to the first element in one of its buckets.
Returns the bucket number where element with key k is located.
Returns the number of buckets present in unordered_multimap container.
Returns the number of elements presents in the nth bucket.
Returns a constant iterator which refers to the first element of the unordered_multimap.
Returns a constant iterator pointing to the first element in one of its buckets.
Returns a constant iterator which points to past-the-end element of the unordered_multimap.
Returns a constant iterator which points to past-the-end element in one of its buckets.
Destroys the unordered_multimap by removing all elements and sets the size of unordered_multimap to zero.
Returns the number of mapped values associated with key k.
Extends container by inserting new element.
Inserts a new element in a unordered_multimap using hint as a position for element.
Tests whether unordered_multimap is empty or not.
Returns an iterator which points to past-the-end element in the unordered_multimap.
Returns an iterator which points to past-the-end element in one of its buckets.
Returns range of elements that matches specific key.
Removes single element of the unordered_multimap from position.
Removes mapped value associated with key k.
Removes range of element from the the unordered_multimap.
Finds an element associated with key k.
Returns an allocator associated with unordered_multimap.
Calculates the hash function object used by the unordered_multimap container.
Extends container by inserting new element in unordered_multimap.
Extends unordered_multimap by inserting new element.
Extends container by inserting new element in unordered_multimap.
Extends container by inserting new element in unordered_multimap by using move semantics.
Extends container by inserting new elements in the unordered_multimap.
Extends unordered_multimap by inserting new element from initializer list.
Returns the function that compares keys for equality.
Returns the current load factor of the unordered_multimap container.
Returns the maximum number of buckets that the unordered_multimap container can have.
Returns the current maximum load factor for the unordered_multimap container.
Assigns new load factor for the unordered_multimap container.
Returns the maximum number of elements can be held by unordered_multimap.
Assigns new contents to the unordered_multimap by replacing old ones and modifies size if necessary.
Move the contents of one unordered_multimap into another and modifies size if necessary.
Copy elements from initializer list to unordered_multimap.
Sets the number of buckets in the container to n or more.
Sets the number of buckets in the container to the most appropriate to contain at least n elements.
Returns the number of elements present in the unordered_multimap.
Exchanges the content of first unordered_multimap with another.
Tests whether two unordered_multimaps are equal or not.
Tests whether two unordered_multimaps are equal or not.
Exchanges the content of first unordered_multimap with another.
 Print
 Add Notes
 Bookmark this page