This document describes how to create templated arrays; that is, an array of a particular type of object.
All array classes are templated; the template value defines the type of object which is to form an element of the array. This is true for arrays of same length and variable length elements. The following example code constructs an array of same length elements of type TMyClass using the flat array buffer CArrayFixFlat<class T> . The array has granularity 16:
To construct an array of TInt values with a granularity of 16, implement code as follows:
After construction, the array contains no elements and no memory is allocated to the array buffer.
CArrayPtrFlat is a specialised array where the elements are pointers to CBase derived objects. To construct an array whose elements are pointers to CMyClass objects:
To construct an array of same length elements of type TMyClass using RArray<class T> :
RArray<TMyClass> array; // this is on the stack ... ... // add entries etc ... array.Close(); // called before the array goes out of scope
To construct an array of pointers to CMyClass objects using RPointerArray<class T> :
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License v1.0.