Insight 21.8.1.
The unordered containers generally provide (slightly) faster access times compared to their ordered counterparts, but they do not maintain any particular order of elements. Other than that they are used in the same ways.
map container keeps its elements in sorted order based on the keys. (And, as with a set, this means that whatever type is used as the key must define the < operator for comparison.)
unordered_map. An unordered_map is similar to a map but does not keep its elements in any particular order. Instead, it uses a structure called a hash table internally that provides for extremely fast access.
unordered_map is the same as for a map. You declare it with the key and value types, and you use the same methods like .insert() and .at() to add and access elements.
unordered_map, the order in which you get the elements is not defined. The order they come out will not necessarily match the order they were added, nor will it be sorted. The ordering of all the elements may even change if you add or remove elements from the map!
unordered_map instead of a map. Notice that nothing but the container type (and include) has changed.
unordered_set in the same way to store unique values without any particular order. The syntax and usage is the same as for a set, you just replace set with unordered_set.
< operator. However, they do require a way to compute a hash for the key type. A hash function is a function that takes a value and produces a fixed-size number (the hash) that represents that value.
unordered_map or elements in an unordered_set. But if you want to use a custom data type as a key or element, you will need to provide your own hash function. We will save that for when we learn about how hash tables work.