Symbian3/SDK/Source/GUID-24D16BF8-7BF1-5FF2-BCA8-E5200A9E8431.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 11 Jun 2010 12:39:03 +0100
changeset 8 ae94777fff8f
parent 7 51a74ef9ed63
child 13 48780e181b38
permissions -rw-r--r--
Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.

<?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-24D16BF8-7BF1-5FF2-BCA8-E5200A9E8431" xml:lang="en"><title>How
to form links</title><shortdesc>To be an element of a list, each element needs to contain a link
object.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>To form a singly linked list of <codeph>CMyClass</codeph> objects, include
the link object <codeph>TSglQueLink</codeph> as a component of <codeph>CMyClass</codeph>:</p>
<codeblock id="GUID-C4ED06AA-9187-5EE6-96C5-39F41C218437" xml:space="preserve">class CMyClass : public CBase
    {
    ...
    TSglQueLink iSlink;
    ...
    };</codeblock>
<fig id="GUID-C1BDFB57-AAD9-55A2-8E02-D9277BCCE122">
<title>Two elements in a linked list</title>
<image href="GUID-C014FC75-732F-558F-8E6A-77DDAA032930_d0e214465_href.png" placement="inline"/>
</fig>
<p>Although any kind of object can be an element of a linked list, most lists
consist of elements which are all of the same type.</p>
<p>An object can participate in more than one list. For example, to allow <codeph>CMyClass</codeph> objects
to participate in two singly linked lists, include two separate <codeph>TSglQueLink</codeph> objects
as components of <codeph>CMyClass</codeph>:</p>
<codeblock id="GUID-A16512BF-ACB8-5E7E-B4B1-FD76208E0FBD" xml:space="preserve">class CMyClass : public CBase
    {
    ...
    TSglQueLink iSlink1;
    ...
    TSglQueLink iSlink2;
    };</codeblock>
<fig id="GUID-AA2CB21D-B848-5ADF-8B0E-7E2928C84DBE">
<title>An example of two elements, in two lists where they are consecutive
elements in both lists</title>
<image href="GUID-773A0EDC-F17C-553B-BEC3-DA990F5064B7_d0e214491_href.png" placement="inline"/>
</fig>
<p>Elements can also be objects constructed from a variety of classes, all
ultimately derived from the same base class, where that base class includes
the link object as a component. For example, if <codeph>CBc</codeph> is a
base class for <codeph>CDc1</codeph> which, in turn, is a base class for <codeph>CDc2</codeph>,
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>
<codeblock id="GUID-A4624B83-5DF4-5923-A3C4-4C67E6FCF47C" xml:space="preserve">class CBc : public CBase
    {
    ...
    TSglQueLink iSlink;
    ...
    };</codeblock>
<codeblock id="GUID-2139FC00-2ADF-5E70-9293-93D347DAF41A" xml:space="preserve">class CDc1 : public CBclass
    {
    ...
    }
</codeblock>
<codeblock id="GUID-4A170483-64BF-559A-B2B1-6F31F8A7F82B" xml:space="preserve">class CDc2 : public CDc1
    {
    ...
    }
</codeblock>
<fig id="GUID-408F856C-86C0-5ED2-A61D-2F81B41566DD">
<title>Example of a linked list of different element types</title>
<image href="GUID-935057C9-8FA9-5B41-A36C-03A825C51B32_d0e214529_href.png" placement="inline"/>
</fig>
<p>Note that the link object is at the same offset in each element in this
list.</p>
<p>New link elements can be inserted at the beginning or the end of the list,
but not into the middle of the list. The functionality for this is provided
by the header <codeph>TSglQue&lt;class T&gt;</codeph>.</p>
</conbody></concept>