Chapter Summary
The associative containers support efficient lookup and retrieval of elements by key. The use of a key distinguishes the associative containers from the sequential containers, in which elements are accessed positionally.
There are eight associative containers, each of which
• Is a map or a set. a map stores key-value pairs; a set stores only keys.
• Requires unique keys or not.
• Keeps keys in order or not.
Ordered containers use a comparison function to order the elements by key. By default, the comparison is the < operator on the keys. Unordered containers use the key type’s == operator and an object of type hash<key_type> to organize their elements.
Containers with nonunique keys include the word multi in their names; those ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access