Symbian3/SDK/Source/GUID-24D16BF8-7BF1-5FF2-BCA8-E5200A9E8431.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-24D16BF8-7BF1-5FF2-BCA8-E5200A9E8431" xml:lang="en"><title>How
       
    13 to form links</title><shortdesc>To be an element of a list, each element needs to contain a link
       
    14 object.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    15 <p>To form a singly linked list of <codeph>CMyClass</codeph> objects, include
       
    16 the link object <codeph>TSglQueLink</codeph> as a component of <codeph>CMyClass</codeph>:</p>
       
    17 <codeblock id="GUID-C4ED06AA-9187-5EE6-96C5-39F41C218437" xml:space="preserve">class CMyClass : public CBase
       
    18     {
       
    19     ...
       
    20     TSglQueLink iSlink;
       
    21     ...
       
    22     };</codeblock>
       
    23 <fig id="GUID-C1BDFB57-AAD9-55A2-8E02-D9277BCCE122">
       
    24 <title>Two elements in a linked list</title>
       
    25 <image href="GUID-C014FC75-732F-558F-8E6A-77DDAA032930_d0e218202_href.png" placement="inline"/>
       
    26 </fig>
       
    27 <p>Although any kind of object can be an element of a linked list, most lists
       
    28 consist of elements which are all of the same type.</p>
       
    29 <p>An object can participate in more than one list. For example, to allow <codeph>CMyClass</codeph> objects
       
    30 to participate in two singly linked lists, include two separate <codeph>TSglQueLink</codeph> objects
       
    31 as components of <codeph>CMyClass</codeph>:</p>
       
    32 <codeblock id="GUID-A16512BF-ACB8-5E7E-B4B1-FD76208E0FBD" xml:space="preserve">class CMyClass : public CBase
       
    33     {
       
    34     ...
       
    35     TSglQueLink iSlink1;
       
    36     ...
       
    37     TSglQueLink iSlink2;
       
    38     };</codeblock>
       
    39 <fig id="GUID-AA2CB21D-B848-5ADF-8B0E-7E2928C84DBE">
       
    40 <title>An example of two elements, in two lists where they are consecutive
       
    41 elements in both lists</title>
       
    42 <image href="GUID-773A0EDC-F17C-553B-BEC3-DA990F5064B7_d0e218228_href.png" placement="inline"/>
       
    43 </fig>
       
    44 <p>Elements can also be objects constructed from a variety of classes, all
       
    45 ultimately derived from the same base class, where that base class includes
       
    46 the link object as a component. For example, if <codeph>CBc</codeph> is a
       
    47 base class for <codeph>CDc1</codeph> which, in turn, is a base class for <codeph>CDc2</codeph>,
       
    48 then the elements of the list can consist of a mix of <codeph>CBc</codeph> or <codeph>CDc1</codeph> or <codeph>CDc2</codeph> objects.</p>
       
    49 <codeblock id="GUID-A4624B83-5DF4-5923-A3C4-4C67E6FCF47C" xml:space="preserve">class CBc : public CBase
       
    50     {
       
    51     ...
       
    52     TSglQueLink iSlink;
       
    53     ...
       
    54     };</codeblock>
       
    55 <codeblock id="GUID-2139FC00-2ADF-5E70-9293-93D347DAF41A" xml:space="preserve">class CDc1 : public CBclass
       
    56     {
       
    57     ...
       
    58     }
       
    59 </codeblock>
       
    60 <codeblock id="GUID-4A170483-64BF-559A-B2B1-6F31F8A7F82B" xml:space="preserve">class CDc2 : public CDc1
       
    61     {
       
    62     ...
       
    63     }
       
    64 </codeblock>
       
    65 <fig id="GUID-408F856C-86C0-5ED2-A61D-2F81B41566DD">
       
    66 <title>Example of a linked list of different element types</title>
       
    67 <image href="GUID-935057C9-8FA9-5B41-A36C-03A825C51B32_d0e218266_href.png" placement="inline"/>
       
    68 </fig>
       
    69 <p>Note that the link object is at the same offset in each element in this
       
    70 list.</p>
       
    71 <p>New link elements can be inserted at the beginning or the end of the list,
       
    72 but not into the middle of the list. The functionality for this is provided
       
    73 by the header <codeph>TSglQue&lt;class T&gt;</codeph>.</p>
       
    74 </conbody></concept>