StableArray<T> is like std::vector<T> (or SimTK::Array_<T>) but more stable in two ways:
#include <StableArray.h>
Public Member Functions | |
StableArray () | |
StableArray (size_t z, const T &ival=T()) | |
StableArray (const StableArray &s) | |
StableArray & | operator= (const StableArray &s) |
~StableArray () | |
bool | empty () const |
bool | empty (size_t i) const |
size_t | size () const |
size_t | nItems () const |
void | resize (size_t newz, const T &ival=T()) |
void | clear () |
void | push_back (const T &t) |
void | pop_back () |
void | insertAt (size_t i, const T &t) |
size_t | findFreeSlot () const |
size_t | findNextItem (size_t i) |
size_t | insert (const T &t) |
void | erase (size_t i) |
const T & | front () const |
T & | front () |
const T & | back () const |
T & | back () |
const T & | operator[] (size_t i) const |
T & | operator[] (size_t i) |
StableArray<T> is like std::vector<T> (or SimTK::Array_<T>) but more stable in two ways:
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.
StableArray | ( | ) | [inline] |
StableArray | ( | size_t | z, | |
const T & | ival = T() | |||
) | [inline, explicit] |
StableArray | ( | const StableArray< T > & | s | ) | [inline] |
References StableArray< T >::empty(), StableArray< T >::nItems(), and StableArray< T >::size().
~StableArray | ( | ) | [inline] |
References StableArray< T >::clear().
T& back | ( | ) | [inline] |
References Array_< T, X >::back(), and StableArray< T >::empty().
const T& back | ( | ) | const [inline] |
References Array_< T, X >::back(), and StableArray< T >::empty().
void clear | ( | ) | [inline] |
References StableArray< T >::nItems(), Array_< T, X >::resize(), and Array_< T, X >::size().
Referenced by StableArray< T >::operator=(), and StableArray< T >::~StableArray().
bool empty | ( | size_t | i | ) | const [inline] |
References Array_< T, X >::size().
bool empty | ( | ) | const [inline] |
void erase | ( | size_t | i | ) | [inline] |
References StableArray< T >::pop_back(), and Array_< T, X >::size().
size_t findFreeSlot | ( | ) | const [inline] |
References StableArray< T >::empty(), StableArray< T >::nItems(), and StableArray< T >::size().
Referenced by StableArray< T >::insert().
size_t findNextItem | ( | size_t | i | ) | [inline] |
References Array_< T, X >::size().
Referenced by StableArray< T >::front().
T& front | ( | ) | [inline] |
References StableArray< T >::findNextItem(), and Array_< T, X >::size().
const T& front | ( | ) | const [inline] |
References StableArray< T >::findNextItem(), and Array_< T, X >::size().
size_t insert | ( | const T & | t | ) | [inline] |
References StableArray< T >::findFreeSlot(), and StableArray< T >::insertAt().
void insertAt | ( | size_t | i, | |
const T & | t | |||
) | [inline] |
References StableArray< T >::push_back(), StableArray< T >::size(), and Array_< T, X >::size().
Referenced by StableArray< T >::insert().
size_t nItems | ( | ) | const [inline] |
StableArray& operator= | ( | const StableArray< T > & | s | ) | [inline] |
T& operator[] | ( | size_t | i | ) | [inline] |
References Array_< T, X >::size().
const T& operator[] | ( | size_t | i | ) | const [inline] |
References Array_< T, X >::size().
void pop_back | ( | ) | [inline] |
References Array_< T, X >::back(), Array_< T, X >::empty(), StableArray< T >::empty(), Array_< T, X >::pop_back(), and Array_< T, X >::size().
Referenced by StableArray< T >::erase().
void push_back | ( | const T & | t | ) | [inline] |
References Array_< T, X >::push_back().
Referenced by StableArray< T >::insertAt().
void resize | ( | size_t | newz, | |
const T & | ival = T() | |||
) | [inline] |
References StableArray< T >::nItems(), Array_< T, X >::resize(), and Array_< T, X >::size().
size_t size | ( | ) | const [inline] |
References Array_< T, X >::size().
Referenced by StableArray< T >::findFreeSlot(), StableArray< T >::insertAt(), StableArray< T >::operator=(), and StableArray< T >::StableArray().