Performance
The unordered associative container type is more optimized compared to its ordered sibling.
Performance - that’s the simple reason - why the unordered associative containers were so long missed in C++. In the example below, one million randomly created values are read from a 10 million big std::map
and std::unordered_map
. The impressive result is that the linear access time of an unordered associative container is 20 times faster than the access time of an ordered associative container. That is just the difference between constant and logarithmic complexity O(log n) of these operations.
Note: The given code might take more time to execute than normal.
Get hands-on with 1400+ tech skills courses.