Learn C++ STL

Lesson 4 of 9 · set and multiset: Sorted, Unique, Found in log n

Module 8 · set and multiset: Sorted, Unique, Found in log n

When to Use set, a Sorted vector or a Hash Set, and When Not To

Free with an accountReading

Maria keeps the different scores of her game in a sorted vector. Every new score goes in at its place, and the game then shows the next score to beat. Kenji uses a set for everything, even for a list he fills once and then searches a million times. Both programs work, and Amara asks each of them one question: what did the job need? This lesson is her answer, with a chart, a flowchart and two measurements.

Checking what this lesson needs for you…

What is inside When to Use set, a Sorted vector or a Hash Set, and When Not To

  1. Six questions before you pick
  2. The comparison chart
  3. The decision flowchart
  4. Kenji's tickets, measured: fill once, ask a million times
  5. Maria's scores, measured: values that keep arriving
  6. The honest default
  7. When not to use a set
  8. flat_set: a sorted vector that looks like a set