As a follow-up to this question, I need a way to access my data by index. But the data needs to be sorted by timestamp, contain a filepath as a value, and be displayed in real-time as new elements are discovered.
Considering that multiple files/folders could potentially contain an identical timestamp, I've decided to go with std::multimap as the container of choice to store my data. However, this complicates the process of populating my List Control, since LVITEM::iItem is an index value used to determine which element of data is to be displayed in a control with the LVS_OWNERDATA flag set (i.e., virtual lists).
I can't seem to find a way to access my data by index in order to get the timestamp keys & filepath values, so what could I do to correct this issue?
You cannot access the content of a
std::multimapby index directly. But what you can do is store your sorted data in astd::multimapand then storeiteratorvalues in a separatestd::vectorand use that as the data source for your ListView. When the ListView asks for data by index, go to yourstd::vectorand use theiteratorat the specified index to access your data in thestd::multimap. When youinsert()a new item in astd::multimap(), it returns aniteratorfor that item, and existingiterators are not invalidated by inserts.