You must give us more details.
Sorry, I guess I didn't explain it very well. I don't really now how to explain it though so I made a kind-of-minimal example that does what I usually experience.
It's pretty large though, but I think the only interesting part begins on the main function. I posted it on
Pastebin (Link) as it's easier to read there. If it's still pretty large to be minimal I'll try to chop off some code.
In this example whenever an object starts getting near the limits of the window, they start "slowing down" until they get erased. I notice this especially on the right-midle objects. On slower machines some blocks start flickering a lot when it starts erasing (But maybe it's not std::vector's fault?).
Here's a preview of the block slowing down:
However there are "tricks" that can make a std::vector efficient at removing in the middle: if elements are cheap to copy, and must not be ordered in the container, you can swap the element to remove with the last element, so that you always remove the last element which is a very fast operation.
I wasn't aware of that, but isn't swap usually a heavy action? Guess I'm going to try it out.
So, the important questions are:
- access how?
- insert/delete where?
I'm used to inserting objects in a linear sequence such as in std::vector with push_back().
In the code I posted I insert new objects with push_back(), access objects that are touching the borders of the window by their index and use erase() to remove them. I think this is what I'm generally after, but is there a better way?
Thanks for all the help and excuse my bad English.