I'm planning to implement a list of Things in C++ where elements might be removed out of order. I don't expect that i'll need any kind of random access (i just need to sweep the list periodically), and the order of items isn't important either.
So I thought of std::list<Thing*> with this->position = insert(lst.end(), thing)
should do the trick. I'd like the Thing class to remember the position of each instance so that i can later easily do lst.erase(this->position)
in constant time.
However, i'm still a bit new to C++ STL containers, and i don't know if it's safe to keep iterators for such a long time. Especially, given that there will be other elements deleted ahead and after the inserted Thing before it's gone.