Main Page Modules Namespaces C++ Classes Compound List File List Index
TemplateTNL::ClassChunker< T > class Reference

TNL::ClassChunker< T > Class Template Reference

#include <tnlDataChunker.h>

Inheritance diagram for TNL::ClassChunker< T >:

TNL::DataChunker

Detailed Description

template<class T>
class TNL::ClassChunker< T >

Templatized data chunker class with proper construction and destruction of its elements.

DataChunker just allocates space. This subclass actually constructs/destructs the elements. This class is appropriate for more complex classes.


Public Member Functions

 ClassChunker (S32 size=DataChunker::ChunkSize)
T * alloc ()
 Allocates and properly constructs in place a new element.

void free (T *elem)
 Properly destructs and frees an element allocated with the alloc method.

void freeBlocks ()
 free all pages currently allocated in the DataChunker


Private Attributes

S32 numAllocated
 number of elements currently allocated through this ClassChunker

S32 elementSize
 the size of each element, or the size of a pointer, whichever is greater

T * freeListHead
 a pointer to a linked list of freed elements for reuse


Constructor & Destructor Documentation

template<class T>
TNL::ClassChunker< T >::ClassChunker S32  size = DataChunker::ChunkSize  )  [inline]
 


Member Function Documentation

template<class T>
T* TNL::ClassChunker< T >::alloc  )  [inline]
 

Allocates and properly constructs in place a new element.

template<class T>
void TNL::ClassChunker< T >::free T *  elem  )  [inline]
 

Properly destructs and frees an element allocated with the alloc method.

template<class T>
void TNL::ClassChunker< T >::freeBlocks  )  [inline]
 

free all pages currently allocated in the DataChunker

Reimplemented from TNL::DataChunker.


Field Documentation

template<class T>
S32 TNL::ClassChunker< T >::numAllocated [private]
 

number of elements currently allocated through this ClassChunker

template<class T>
S32 TNL::ClassChunker< T >::elementSize [private]
 

the size of each element, or the size of a pointer, whichever is greater

template<class T>
T* TNL::ClassChunker< T >::freeListHead [private]
 

a pointer to a linked list of freed elements for reuse