Symbian3/SDK/Source/GUID-E161AB84-1B24-53AF-B313-D68CF9F8EE60.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 13 Aug 2010 16:47:46 +0100
changeset 14 578be2adaf3e
parent 13 48780e181b38
permissions -rw-r--r--
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582

<?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-E161AB84-1B24-53AF-B313-D68CF9F8EE60" xml:lang="en"><title>Pointers
to the start and end of contiguous regions</title><shortdesc>The <codeph>Back()</codeph> and <codeph>End()</codeph> functions
point to locations in memory for flat and segmented arrays.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>For those arrays of same length elements which are derived from <codeph>CArrayFix&lt;class T&gt;</codeph>,
the elements are contained within an array buffer which can be implemented
as a flat buffer or as a segmented buffer. A flat buffer is implemented as
a single contiguous region of memory while a segmented buffer is implemented
as a set of separate but linked regions of memory </p>
<p>Given the position of an element within an array, it can be useful to fetch
a pointer to the first byte following the end of the contiguous region of
memory containing that element (the <i>end</i> pointer). Similarly, it can
be useful to fetch a pointer to the <i>beginning</i> of a contiguous region
of memory (the <i>back</i> pointer).</p>
<section id="GUID-DB6D5E2F-CFEE-47EC-B38D-9D0DC13B994D"><title>Array of same length elements</title> <p>An array of same
length elements uses the <codeph>End()</codeph> function to fetch the end
pointer and the <codeph>Back()</codeph> function to fetch the back pointer.
The implementation of these two functions differs between a fixed flat array
and a fixed segmented array.</p> </section>
<section id="GUID-48756A91-9B8F-4BA8-A0CF-52970F8B41CC"><title>Flat array</title> <p>For a flat array — i.e. an array whose
buffer is implemented using a flat buffer — the end pointer simply points
to the first byte following the single region of memory containing the array
buffer. The back pointer simply points to the first byte of the single region
of memory (as illustrated below); <codeph>End()</codeph> always returns a
pointer to the first byte following the end of the buffer, while <codeph>Back()</codeph> always
returns a pointer to the beginning of the buffer.</p> <fig id="GUID-D4084F4C-B928-5779-A58F-CB495A74EE68">
<title>End() and Back() in fixed flat arrays</title>
<image href="GUID-81A5784D-A0C6-5108-9E7B-5D39C6743B1A_d0e221845_href.png" placement="inline"/>
</fig> </section>
<section id="GUID-27F85346-3B08-4E06-A80D-A5B708105659"><title>Segmented array</title> <p>For a segmented array, the situation
is different (as illustrated below). Looking at the segment containing elements <codeph>n</codeph> and <codeph>n+1</codeph>, <codeph>End()</codeph> returns a pointer to the first byte following the end of that segment. In
fact, <codeph>End()</codeph> returns the same pointer value for all elements
in that segment. <codeph>Back()</codeph> returns a pointer to the beginning
of that segment for element <codeph>n+1</codeph> and for all <i>subsequent</i> elements
in that segment. However, for the <i>first</i> element in that segment, <codeph>Back()</codeph> returns
a pointer to the beginning of the <i>previous</i> segment. For the very first
element in the array, <codeph>Back()</codeph> returns a pointer with a NULL
value.</p> <fig id="GUID-90C05AF9-9048-557E-95DD-49A19F856EF0">
<title>End() and Back() in fixed segmented arrays</title>
<image href="GUID-C0CFFE13-579C-5A93-9B63-DC2DCF98EC61_d0e221894_href.png" placement="inline"/>
</fig> </section>
<section id="GUID-165D9F3E-3948-4DC0-9632-FF70480C495C"><title>See also</title> <p><xref href="GUID-112AAFA5-B4C9-5B62-A106-FB5097C13A0E.dita">Dynamic
Buffers Guide</xref>.</p> </section>
</conbody></concept>