I am looking for an STL container that works like std :: multimap but has constant access time to the random nth element. I need this because I have such a structure in memory that is std :: multimap for many reasons, but the elements stored in it should be presented to the user in a list. Since the amount of data is huge, I use a list box with virtual elements (i.e. list control polls for the value in row X).
As a workaround, I am currently using an additional std :: vector to store the “indices” in std :: map, and I populate it like this:
std::vector<MMap::data_type&> vec;
for (MMap::iterator it = mmap.begin(); it != mmap.end(); ++it)
vec.push_back((*it).second);
But this is not a very elegant solution.
Is there any such filter?
source
share