Symbian3/SDK/Source/GUID-59ED6D14-0976-58AE-8DDC-73F051866406.dita
changeset 7 51a74ef9ed63
child 8 ae94777fff8f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Symbian3/SDK/Source/GUID-59ED6D14-0976-58AE-8DDC-73F051866406.dita	Wed Mar 31 11:11:55 2010 +0100
@@ -0,0 +1,46 @@
+<?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-59ED6D14-0976-58AE-8DDC-73F051866406" xml:lang="en"><title>How
+to construct a header</title><shortdesc>The header of a linked list needs to know the type of data for
+each list element, and where in each element the pointer to the next element
+can be found.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
+<p>In order to construct a header, two important pieces of information are
+needed:</p>
+<ul>
+<li id="GUID-5BD8E773-5793-5C52-BF07-62FF1839F19A"><p>the <i>type</i> of object
+which forms the elements.</p> </li>
+<li id="GUID-9E43534B-D692-53CE-83D9-FE4F1B2DFC42"><p>the <i>offset</i> of
+the link object from the start of the element.</p> </li>
+</ul>
+<p>To create a header for a singly linked list of <codeph>CMyClass</codeph> elements,
+defined as:</p>
+<codeblock id="GUID-8851C435-33CD-5F1C-95E3-60CEC2770D64" xml:space="preserve">class CMyClass : public CBase
+    {
+    ...
+    TSglQueLink iSlink;
+    ...
+    };</codeblock>
+<p>construct a <codeph>TSglQue</codeph> as follows:</p>
+<codeblock id="GUID-D634E7AB-9240-5F0E-9D36-BE476B038842" xml:space="preserve">TSglQue&lt;CMyClass&gt; queHeader(_FOFF(CMyClass,iSlink));</codeblock>
+<p>The <codeph>TSglQue</codeph> class takes a class template parameter which
+defines the type of object which is to form an element of the list. In this
+example, objects of type <codeph>CMyClass</codeph> form the elements of the
+list.</p>
+<p>The <codeph>_FOFF</codeph> macro (i.e. the "field offset" macro) calculates
+the offset of the component link object within the element. In this example,
+the required value is the offset of the <codeph>iSlink</codeph> data member
+from the start of <codeph>CMyClass</codeph>. </p>
+<fig id="GUID-3B9C78A4-02FC-5D63-AFD2-53996F9CAEC7">
+<title>Links in singly linked lists</title>
+<image href="GUID-FB654184-C256-546F-AF6C-E0FADA78D5D0_d0e218352_href.png" placement="inline"/>
+</fig>
+</conbody></concept>
\ No newline at end of file