Simbody  3.6
SimTK::StableArray< T > Class Template Reference

StableArray<T> is like std::vector<T> (or SimTK::Array_<T>) but more stable in two ways: More...

Public Member Functions

 StableArray ()
 
 StableArray (size_t z, const T &ival=T())
 
 StableArray (const StableArray &s)
 
StableArrayoperator= (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)
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ StableArray() [1/3]

template<class T >
SimTK::StableArray< T >::StableArray ( )
inline

◆ StableArray() [2/3]

template<class T >
SimTK::StableArray< T >::StableArray ( size_t  z,
const T &  ival = T() 
)
inlineexplicit

◆ StableArray() [3/3]

template<class T >
SimTK::StableArray< T >::StableArray ( const StableArray< T > &  s)
inline

◆ ~StableArray()

template<class T >
SimTK::StableArray< T >::~StableArray ( )
inline

Member Function Documentation

◆ operator=()

template<class T >
StableArray& SimTK::StableArray< T >::operator= ( const StableArray< T > &  s)
inline

◆ empty() [1/2]

template<class T >
bool SimTK::StableArray< T >::empty ( ) const
inline

◆ empty() [2/2]

template<class T >
bool SimTK::StableArray< T >::empty ( size_t  i) const
inline

◆ size()

template<class T >
size_t SimTK::StableArray< T >::size ( ) const
inline

◆ nItems()

template<class T >
size_t SimTK::StableArray< T >::nItems ( ) const
inline

◆ resize()

template<class T >
void SimTK::StableArray< T >::resize ( size_t  newz,
const T &  ival = T() 
)
inline

◆ clear()

template<class T >
void SimTK::StableArray< T >::clear ( )
inline

◆ push_back()

template<class T >
void SimTK::StableArray< T >::push_back ( const T &  t)
inline

◆ pop_back()

template<class T >
void SimTK::StableArray< T >::pop_back ( )
inline

◆ insertAt()

template<class T >
void SimTK::StableArray< T >::insertAt ( size_t  i,
const T &  t 
)
inline

◆ findFreeSlot()

template<class T >
size_t SimTK::StableArray< T >::findFreeSlot ( ) const
inline

◆ findNextItem()

template<class T >
size_t SimTK::StableArray< T >::findNextItem ( size_t  i)
inline

◆ insert()

template<class T >
size_t SimTK::StableArray< T >::insert ( const T &  t)
inline

◆ erase()

template<class T >
void SimTK::StableArray< T >::erase ( size_t  i)
inline

◆ front() [1/2]

template<class T >
const T& SimTK::StableArray< T >::front ( ) const
inline

◆ front() [2/2]

template<class T >
T& SimTK::StableArray< T >::front ( )
inline

◆ back() [1/2]

template<class T >
const T& SimTK::StableArray< T >::back ( ) const
inline

◆ back() [2/2]

template<class T >
T& SimTK::StableArray< T >::back ( )
inline

◆ operator[]() [1/2]

template<class T >
const T& SimTK::StableArray< T >::operator[] ( size_t  i) const
inline

◆ operator[]() [2/2]

template<class T >
T& SimTK::StableArray< T >::operator[] ( size_t  i)
inline

The documentation for this class was generated from the following file: