diff -r 89d6a7a84779 -r 25a17d01db0c Symbian3/PDK/Source/GUID-27C933F7-4634-57C8-B3D2-45C5563FECA4.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/PDK/Source/GUID-27C933F7-4634-57C8-B3D2-45C5563FECA4.dita Fri Jan 22 18:26:19 2010 +0000 @@ -0,0 +1,55 @@ + + + + + +How +to use dynamic arraysThis 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:

+CArrayFixFlat<TMyClass> array; +... +array = new (ELeave) CArrayFixFlat<TInt>(16); +... +

To construct an array of TInt values with a granularity of +16, implement code as follows:

+CArrayFixFlat<TInt>* array; +... +array = new (ELeave) CArrayFixFlat<TInt>(16); +

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:

+CArrayPtrFlat<CMyClass>* array; +... +array = new (ELeave) CArrayPtrFlat<CMyClass>(16); +

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>:

+RPointerArray<CMyClass> array; // this is on the stack +... +CMyClass* ptr = new (ELeave) CMyClass; +... +array.Append(ptr); +... +array.ResetAndDestroy(); // called before the array goes + // out of scope +
\ No newline at end of file