Original Post
I have a base class containing a vector. Objects can be registered with it, and each one is allocated some 'slots' in the vector. Ie the 1st object asks for 5 slots and gets allocated vector[0]-vector[4], the 2nd object registered wants 3 slots and is allocated [5] to [7], and so on. I can use resize/reserve to endure the vector is large enough, each time an object is registered. But say I have the following vector: vector{ 1.Object #1 2.Object #1 3.Object #1 4.Object #2 5.Object #2 6.Object #2 7.Object #3 8.Object #3 9.Object #3 } I want to unregister Object #2, which leaves: vector{ 1.Object #1 2.Object #1 3.Object #1 4.--- 5.--- 6.--- 7.Object #3 8.Object #3 9.Object #3 } My questions are about the behaviour of vector. If I use vector.remove(), do slots 4-6 just get abandoned or does the rest of the vector get moved up 3 places? Is it going to take more and more memory to register an object, then unregister it many times or will the vector be smart? What about using the array operator on the vector after removing items from the middle - will vector[5] still have the same value?