@James McNellis: I mean that when I insert or remove any element this should not affect on others' position. E.g if I have a container with 500 elements and I removed all first 499, the last should be 500th anyway and container's size should not change aswell.
–
szxJun 12 '10 at 17:35

@serejko: Ok. Just don't add or remove objects from the middle then, or, instead of adding or removing objects from the middle, replace them with default constructed objects or with some sentinel value.
–
James McNellisJun 12 '10 at 17:37

Interesting. Is your goal is to expose a mapping from integers to SLOTS, where those SLOTS may contain a value? Or is your goal to preserve the underlying address of each element and the underlying address of the start of the internal array itself? Presumably you have a reason that you need either the position of the elements or the mapping from integer keys to elements to be preserved after an element is "removed". What is that reason?

The map<> or vector<> implementations mentioned above may not work because the remove, erase, find, etc. operations will remove, rearrange, or inspect the integers which you consider to be "removed".

Unfortunately, I think this may be a case where you need to roll your own using a wrapper around vector<optional<T> > or vector<T*>, depending upon how you define remove.