
8 Sep
2004
8 Sep
'04
6:17 a.m.
I'm looking for an associative container which is optimized for one-time insertion and avoids much of the overhead of std::map therefore. IIRC Andrei once published something like this: a vector of pairs that was sorted once and accessed by binary search.
std::vector + std::sort + std::binary_search?
[snip]
Is there something similar in boost?
Not that I'm aware of, but that doesn't mean there isn't.
I think there's a template called 'AssocVector' in Andrei's Loki library, which was used in place of std::map in Modern C++ Design. It was a vector of pairs, overlaid with the map interface, implemented as suggested above. Matt