Associative Containers: Performance Comparison

Modern C++ has eight associative containers, but we should use std::map and std::unordered_map. Why? Let’s disucss in this lesson.

In 95% of our use-cases, we use std::map or std::unordered_map. In fewer cases, we do not need the value associated with the key. Before we begin this lesson and give an overview of numbers to both associative containers, here is one simple rule to remember:

If we want to have a container with ordered key/value associations, use std::map; if not, use a std::unordered_map.

A Phone Book

The ...

Get hands-on with 1400+ tech skills courses.