Symbian3/SDK/Source/GUID-59ED6D14-0976-58AE-8DDC-73F051866406.dita
changeset 7 51a74ef9ed63
child 8 ae94777fff8f
equal deleted inserted replaced
6:43e37759235e 7:51a74ef9ed63
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept id="GUID-59ED6D14-0976-58AE-8DDC-73F051866406" xml:lang="en"><title>How
       
    13 to construct a header</title><shortdesc>The header of a linked list needs to know the type of data for
       
    14 each list element, and where in each element the pointer to the next element
       
    15 can be found.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    16 <p>In order to construct a header, two important pieces of information are
       
    17 needed:</p>
       
    18 <ul>
       
    19 <li id="GUID-5BD8E773-5793-5C52-BF07-62FF1839F19A"><p>the <i>type</i> of object
       
    20 which forms the elements.</p> </li>
       
    21 <li id="GUID-9E43534B-D692-53CE-83D9-FE4F1B2DFC42"><p>the <i>offset</i> of
       
    22 the link object from the start of the element.</p> </li>
       
    23 </ul>
       
    24 <p>To create a header for a singly linked list of <codeph>CMyClass</codeph> elements,
       
    25 defined as:</p>
       
    26 <codeblock id="GUID-8851C435-33CD-5F1C-95E3-60CEC2770D64" xml:space="preserve">class CMyClass : public CBase
       
    27     {
       
    28     ...
       
    29     TSglQueLink iSlink;
       
    30     ...
       
    31     };</codeblock>
       
    32 <p>construct a <codeph>TSglQue</codeph> as follows:</p>
       
    33 <codeblock id="GUID-D634E7AB-9240-5F0E-9D36-BE476B038842" xml:space="preserve">TSglQue&lt;CMyClass&gt; queHeader(_FOFF(CMyClass,iSlink));</codeblock>
       
    34 <p>The <codeph>TSglQue</codeph> class takes a class template parameter which
       
    35 defines the type of object which is to form an element of the list. In this
       
    36 example, objects of type <codeph>CMyClass</codeph> form the elements of the
       
    37 list.</p>
       
    38 <p>The <codeph>_FOFF</codeph> macro (i.e. the "field offset" macro) calculates
       
    39 the offset of the component link object within the element. In this example,
       
    40 the required value is the offset of the <codeph>iSlink</codeph> data member
       
    41 from the start of <codeph>CMyClass</codeph>. </p>
       
    42 <fig id="GUID-3B9C78A4-02FC-5D63-AFD2-53996F9CAEC7">
       
    43 <title>Links in singly linked lists</title>
       
    44 <image href="GUID-FB654184-C256-546F-AF6C-E0FADA78D5D0_d0e218352_href.png" placement="inline"/>
       
    45 </fig>
       
    46 </conbody></concept>