I'd like to know which STL container would be most appropriate for a 'continually' changing collection of elements in terms of performance. The elements represent objects in a given viewing space, and as the view changes and objects move in and out of view, the collection of objects needs to be updated. Every time the view is updated, I get a std::vector of objects that should be in the scene, sorted by UID (lets call this List A). I want to run a check that:
removes objects that are no longer visible from the current list of things actually in the scene (call this List B) based on List A
adds new objects that are now visible to List B, again based on List A
Two to four thousand objects is probably the upper limit of the number of objects ever seen. I can't use a bit-mapped vector though since object UIDs run into the billions. I was thinking I could use std::map for List B. My proposed strategy for updating List B is:
For each UID 'i' in List B, search for UID 'i' in List A (using std::lower_bound). If the UID does not exist in List A, remove it from List B.
For each UID 'i' in List A, search for UID 'i' in List B (using std::map::lower_bound). If the UID does not exist in List B, add it.
So I'd like some advice, specifically if I'm using the right container type. I didn't think std::vector would be a good choice for List B because insertions/removals would be expensive and I'd have to explicitly sort if I wanted to use a binary search over std::find. Other than that though, I don't know much about the other container types and whether or not they're more appropriate.
I'd also like to know if the general method I've chosen to update List B is the most efficient way to do it, and I'm not just missing something obvious.