Chapter 21. STL map and multimap

The standard template library (STL) supplies the programmer with container classes that help with applications that require frequent and quick searches.

In this lesson, you will learn

  • An introduction to the STL map and multimap

  • Basic STL map and multimap operations

  • Customizing behavior using a sort predicate

A Brief Introduction

The map and multimap are key-value pair containers that allow for a lookup on the basis of a key. The difference between the map and the multimap is that only the latter allows for duplicates, whereas the former can store only unique keys.

To facilitate quick searching, STL implementations of the map and multimap internally look like a binary tree. This means that elements inserted in a map or ...

Get Sams Teach Yourself C++ in One Hour a Day, Sixth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.