StableArray<T> is like std::vector<T> (or SimTK::Array_<T>) but more stable in two ways:
More...
template<class T>
class SimTK::StableArray< T >
StableArray<T> is like std::vector<T> (or SimTK::Array_<T>) but more stable in two ways:
- the addresses of the inserted items never change, even if the array has to be resized, and
- the index of an inserted item never changes either.
The above means that once you insert an item (meaning that a copy of it resides in the StableArray), you can save the address of that copy and/or its index and be certain that adding or deleting other items will leave those unaffected. Once an item has been erased, however, we will feel free to reuse both the heap it once consumed and its index.
As your punishment for the crime of enjoying this stability guarantee, consecutive elements of a StableArray are not consecutive in memory.
CAUTION: this is not suited for use across binary interfaces because the implementation is fully exposed.