std::unordered_multimap
By blending the principles of std::unordered_map
and the flexibility of multiplicity, this container allows a single key to be associated with multiple values without the need to maintain a specific order.
Purpose and suitability
std::unordered_multimap
is a hash-based container that permits multiple values to be associated with a single key. Unlike std::unordered_map
, it doesn’t enforce unique keys. It’s especially apt in the following scenarios:
- When quick average-case lookup times are desired
- When you anticipate multiple values for the same key
- When key order doesn’t matter, as elements aren’t stored in any particular order
Choose std::unordered_multimap
for situations that require non-unique keys and swift lookups. If order or unique keys matter, consider other options.
Ideal use cases
The following are some of the ideal use cases for std::unordered_multimap
:
- One-to-many relationships...