The types of array

Describes the types of array available.

General arrays of objects

Six general types of array can be constructed:

  • CArrayFixFlat<Class T> : an array of elements, all having the same length. It uses a flat array buffer implemented by a CBufFlat object. The array object itself is allocated on the heap.

  • CArrayFixSeg<Class T> : an array of elements, all having the same length. It uses a segmented array buffer implemented by a CBufSeg object. The array object itself is allocated on the heap.

  • CArrayVarFlat<Class T> : an array of elements having varying lengths. It uses a flat array buffer implemented by a CBufFlat object. The array object itself is allocated on the heap.

  • CArrayVarSeg<Class T> : an array of elements having varying lengths. It uses a segmented array buffer implemented by a CBufSeg object. The array object itself is allocated on the heap.

  • CArrayPakFlat<Class T> : an array of elements having varying lengths. It uses a flat array buffer implemented by a CBufFlat object. The length value of an element precedes the element itself within the array buffer. The array object itself is allocated on the heap.

  • RArray<class T> : a simple array of elements, all having the same length. The array buffer is flat and is implemented by the array class as a simple piece of linear memory. The array object itself can be constructed on the program stack.

General arrays of pointers

There are three arrays which can be used when the elements are pointers to CBase derived objects. They allow type-safe access to CBase derived objects:

  • CArrayPtrFlat<class T> : an array of pointers using a flat array buffer implemented by a CBufFlat object. The array object itself is allocated on the heap.

  • CArrayPtrSeg<class T> : an array of pointers using a segmented array buffer implemented by a CBufSeg object. The array object itself is allocated on the heap.

  • RPointerArray<class T> : a simple array of pointers using a flat array buffer implemented by the array class as a simple piece of linear memory. The array object itself can be constructed on the program stack.

Specialised arrays

There are two specialised arrays of untyped elements, all having the same length, which can be used as data members of a base class in a thin template class/base class pair. These classes are useful in situations where the type of elements forming the array cannot be known in advance:

  • CArrayFixFlat<TAny> . An array of untyped elements all having the same length. It uses a flat array buffer implemented by a CBufFlat object.

  • CArrayFixSeg<TAny> . An array of untyped elements all having the same length. It uses a segmented array buffer implemented by a CBufSeg object.

There are two specialised arrays of untyped elements, having varying lengths, which can be used as data members of a base class in a thin template class/base class pair. These classes are useful in situations where the type of element forming the array is known only at the time the class is created (i.e. at compile time):

  • CArrayVar<TAny> . An array of untyped elements with varying lengths.

  • CArrayPak<TAny> . An array of packed (variable length) elements.

There are two template specialisations of RArray<class T> .

  • RArray<TInt> . An array of signed integers

  • RArray<TUint> . An array of signed integers.