Module 9 · map and multimap: A Key Finds Its Value
When to Use map, a Sorted vector of Pairs or a Plain Array, and When Not To
Free with an accountReading
Maria counts the marks of a 10,000,000-row exam log in a map<int, int>, although every mark is a whole number from 0 to 100. Kenji keeps his café's menu as a sorted vector of (name, price) pairs, and every new item goes in at its place. Both programs work. Amara asks each of them one question: what did the job need? This lesson is her answer, with a chart, a flowchart and three measurements.
Checking what this lesson needs for you…
What is inside When to Use map, a Sorted vector of Pairs or a Plain Array, and When Not To
- Five questions before you pick
- The comparison chart
- The decision flowchart
- Maria's marks, measured: an array against a map
- Kenji's items, measured: fill once, then a million lookups
- Kenji's items, measured: keys that keep arriving
- The honest default
- When not to use a map
- flat_map: a sorted vector that looks like a map