Embercode
✕
Maps and Sets (C++)Quick quiz

Iteration and counts

8 questions. Covers Multisets and counted maps.

Questions 1 to 5 of 8

  1. 1. A multiset holds the values 8, 8 and 9. What does ms.erase(8) do?
  2. 2. Why should a program not depend on the order of the items in an unordered_map loop?
  3. 3. Which function returns an iterator to the first element that is not less than a value, or end() if every element is smaller?
  4. 4. In a range-based for loop over an unordered_map, calling erase on the current key and then letting the loop move on is safe, because the loop refreshes its iterator after each erase.
  5. 5. A counted map may keep a key whose count has dropped to 0, because size() counts only keys that still have stock.

5 question(s) left on this page.