All arrays have an array buffer. The implementation of this buffer and the way it is used depend on the specific type of array.
In fixed length arrays and packed arrays the elements are contained within the array buffer itself.
In variable length arrays each element is contained within its own heap cell and the array buffer contains pointers to the elements.
Logically, an array buffer is linear but, physically, it can be organised either as a flat buffer or a segmented buffer.
In general, you can choose between array classes which use a flat array buffer and array classes which use a segmented array buffer. The choice depends on how the array is to be used.
A segmented array buffer is implemented using a CBufSeg
object.
A flat array buffer is implemented either:
directly by the array as a piece of linear memory.
or
using a CBufFlat
object.
The first has a simple and efficient implementation but has some restrictions on the size of an array element and is limited to holding fixed length elements. The second is a more general implementation but is only limited by the memory available.