Array of packed elements, flat array

Describes arrays of packed elements in a flat.

This is a CArrayPakFlat<class T> object whose elements can have different lengths but are physically contiguous within a flat array buffer. Each element is preceded by a TInt value to record the length of that element.

A flat buffer always occupies a single cell allocated from the heap and is always extended by the process of reallocation. A flat array buffer is implemented using a CBufFlat object.

The following diagram illustrates how elements are organised within the array buffer:

This kind of array is suitable for a small number of objects or for a moderately large but fixed maximum number of objects. It is not suitable for large arrays with a high turnover of elements.

A packed array has the advantage over a variable flat array in having a smaller memory overhead for each element. The disadvantage is that the elements and their preceding TInt values occupy a single cell which has a higher risk of reallocation failure in times of low memory availability.

This class is immediately derived from the abstract template base class CArrayPak<class T> which is itself derived from the abstract non-templated base class CArrayPakBase .