Dynamic linear pool of objects
![]() | increment_ linear growth increment |
![]() | vector_ dynamic array of pointers |
Dynamic linear pool of objects. This is a template for a dynamic pool of objects. The design is very similar to the dynamic array of pointers. A pool is defined to be an array of pointers to preallocated default objects. Whenever a new object is needed, it can be accessed from the pool with the use() member function. The size of the pool extends automatically if its initial limit is reached. This pool is a linear pool, i.e. we can rely upon their index to be sequential. So in order to return a specific object into the pool's disposal, all objects having larger indices have to be free (like a reverse LIFO - last out first back). The free member function returns objects to the pool's disposal. Upon destruction, all pool objects are destroyed using their destructor. It does not make sense to have a copy constructor or assignment op.
LinPool( size_t capacity=0, size_t increment=0 )
const T*& operator ()( size_t index ) const
T*& operator ()( size_t index )
const T*& operator []( size_t index ) const
T*& operator []( size_t index )
T*& use( void )
size_t length( void ) const
size_t free( size_t count = 0)
alphabetic index hierarchy of classes