Symbian3/SDK/Source/GUID-0AF14EE0-D4FD-53EA-B7E5-10724E3FA0DF.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 21 Jan 2010 18:18:20 +0000
changeset 0 89d6a7a84779
permissions -rw-r--r--
Initial contribution of Documentation_content according to Feature bug 1266 bug 1268 bug 1269 bug 1270 bug 1372 bug 1374 bug 1375 bug 1379 bug 1380 bug 1381 bug 1382 bug 1383 bug 1385

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-0AF14EE0-D4FD-53EA-B7E5-10724E3FA0DF" xml:lang="en"><title>How
to resize an array</title><shortdesc>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.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>In a <codeph>CArrayFixFlat&lt;class T&gt;</codeph> or a <codeph>CArrayFixSeg&lt;class T&gt;</codeph> array,
the number of elements in an array can be changed, either decreased or increased,
using the <codeph>ResizeL()</codeph> function.</p>
<p>In the following code fragment, <codeph>ResizeL()</codeph> 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 <codeph>ResizeL()</codeph> deletes
all elements from position one onwards, leaving only the element at position
zero.</p>
<codeblock id="GUID-EB765A8F-D630-50A1-8CF4-707DFAAC5862" xml:space="preserve">CArrayFixFlat&lt;TElement&gt;* fixflat;
fixflat = new (ELeave) CArrayFixFlat&lt;TElement&gt;(3);
...
fixflat-&gt;ResizeL(1);</codeblock>
<p>Call <codeph>ResizeL()</codeph> 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 <codeph>ResizeL()</codeph> constructs
two new elements at positions one and two. In this example, the new elements
inserted at positions one and two are <codeph>TElement</codeph> type objects,
constructed using the <codeph>TElement</codeph>  <i>default constructor</i>.
It is therefore essential that a default constructor exists before using this
function.</p>
<codeblock id="GUID-BCE6F87D-D2EB-5A38-8CAF-675DBFE9E6B6" xml:space="preserve">fixflat-&gt;ResizeL(3);</codeblock>
<p>There is an overloaded variant of <codeph>ResizeL()</codeph> which takes
a reference to a <codeph>TElement</codeph> 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 <codeph>theElement</codeph> object.</p>
<codeblock id="GUID-EA125434-F6B2-598B-8143-55BE1F2D2996" xml:space="preserve">_LIT(KTextXXX,"XXX");
theElement.iData = KTextXXX;
fixflat-&gt;ResizeL(5,theElement);</codeblock>
</conbody></concept>