std::flat_multiset
std::flat_multiset
is a container that was introduced in the C++ STL that’s designed to store elements in a sorted order. Unlike std::multiset
, which is typically implemented as a red-black tree, std::flat_multiset
stores its elements in a contiguous memory block, similar to a std::vector
container. This design choice offers improved cache performance due to data locality, making it efficient for scenarios where the container is not frequently modified after being filled.
Purpose and suitability
Std::flat_multiset
is a container that stores elements in a sorted array, similar to std::flat_set
, but allows for multiple occurrences of equivalent elements.
This container offers the following:
- Efficient lookup times thanks to its sorted nature
- Improved cache locality and predictability in memory usage
It’s especially suitable in the following scenarios:
- When duplicates are permissible and you need sorted access
- When...