Object deletion troubles

 

I am using a loop to go through every object and deleting and creating objects while in the loop, and am having some difficulties. If I delete an object, what happens to the index array? If I delete an object with an index of 5, for example, would all object previously with an index of 6 and over immediately shift down so that 5 now points to the next object? What if I create an object immediately after deleting one--would the new object have the same index as the deleted object, or would it be indexed at the very end, or at 0 with every other object shifting up 1? Thanks for your assistance.


(This would be good information to have in the documentation for anything identified by an index, as I find some things are indexed from oldest to newest and others from newest to oldest, causing a lot of confusion.)

 

maybe you sholuld delete object in 6 5 4 3 2 1 0 order .

 
I'm not deleting all object, just ones that meet specific conditions, and I'm looping through all objects to find them. The problem is after deleting an object I don't want the loop to redo a previous object or skip the next. And the same if I insert an object while inside the loop.