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-E2CB0826-FC44-5AC9-BBB1-B449073484F3" xml:lang="en"><title>Array
capacity and granularity</title><shortdesc>Describes the granularity and capacity of a dynamic array.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>The <i>capacity</i> of an array is the number of elements which the array
can hold or represent within the space currently allocated to its array buffer.</p>
<p>For a flat array buffer, the increase in capacity of a buffer, when the
insertion of an additional element causes the buffer to be re-allocated, is
termed the <i>granularity</i> of the array. For example, adding a fifth element
to a fixed flat array constructed with a granularity of four, causes the array
buffer to be re-allocated so that its capacity increases from four to eight
elements.</p>
<fig id="GUID-B752C5C8-FFA3-5F27-8D75-C951EE2D1432">
<image href="GUID-4922D80F-009D-56CE-B255-FDAF9C247667_d0e190442_href.png" placement="inline"/>
</fig>
<p>For a segmented array buffer, the granularity defines the capacity of a
single segment. A segmented array buffer is always expanded by allocating
additional segments.</p>
<p>The granularity of an array is defined at construction time.
The choice of value depends on the use to be made of the array and needs careful
consideration. Too small a value for an array with a high turnover of elements
can incur considerable overhead from the process of allocating memory. Too
large a value can result in wasted space if insufficient new elements are
subsequently added.</p>
<section id="GUID-33BD77F1-C787-49D9-87C0-011900038A64"><title>See also</title> <p><xref href="GUID-112AAFA5-B4C9-5B62-A106-FB5097C13A0E.dita">Using
Dynamic Buffers</xref>.</p> </section>
</conbody></concept>