For fixed flat and fixed segmented arrays, it is possible to resize the array. If the array is shortened, then the trailing elements are deleted. If the array is extended, then new blank elements are created using the default constructor.
In a CArrayFixFlat<class T> or a CArrayFixSeg<class T> array, the number of elements in an array can be changed, either decreased or increased, using the ResizeL() function.
In the following code fragment, ResizeL() changes the size of an array so that it contains only one element. If the array originally had more than one element, then this call to ResizeL() deletes all elements from position one onwards, leaving only the element at position zero.
CArrayFixFlat<TElement>* fixflat; fixflat = new (ELeave) CArrayFixFlat<TElement>(3); ... fixflat->ResizeL(1);
Call ResizeL() again to change the size of the array to contain a greater number of elements, in this case three. If the array originally had only one element (for example), this call to ResizeL() constructs two new elements at positions one and two. In this example, the new elements inserted at positions one and two are TElement type objects, constructed using the TElement default constructor. It is therefore essential that a default constructor exists before using this function.
fixflat->ResizeL(3);
There is an overloaded variant of ResizeL() which takes a reference to a TElement object. A bit-wise copy of this referenced object supplies the new elements. In the following code fragment the two extra elements are bit-wise copies of the theElement object.
_LIT(KTextXXX,"XXX"); theElement.iData = KTextXXX; fixflat->ResizeL(5,theElement);
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.