Symbian3/SDK/Source/GUID-9309D482-8931-58FC-9B34-D0E5E942E404.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?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-9309D482-8931-58FC-9B34-D0E5E942E404" xml:lang="en"><title>Array
keys</title><shortdesc>This document provides an introduction to array keys.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>A key is used by an array for sorting and finding elements and can also
be used to locate the insertion position for new elements.</p>
<p>The characteristics of a key are defined by a key object, constructed from
one of the three concrete classes: <codeph>TKeyArrayFix</codeph>, <codeph>TKeyArrayVar</codeph> and <codeph>TKeyArrayPak</codeph>.
In general, the choice of key class depends on the type of array being used
and the specific member function of that array.</p>
<p><codeph>TKeyArrayFix</codeph> is used by the following functions accessible
through the <codeph>CArrayFixFlat</codeph> and <codeph>CArrayFixSeg</codeph> classes:</p>
<ul>
<li id="GUID-0E7B4699-4F6C-55C2-89B1-745150DC093F"><p><codeph>Sort()</codeph> </p> </li>
<li id="GUID-A93FD22C-3AF2-52B9-A0A0-97AD55A4AD10"><p><codeph>InsertIsqL()</codeph> </p> </li>
<li id="GUID-517388FF-9C57-57C2-B298-0CAAB089F115"><p><codeph>Find()</codeph>  </p> </li>
<li id="GUID-361EC51C-F9C6-59CE-94F3-080B709A5CEE"><p><codeph>FindIsq()</codeph> </p> </li>
</ul>
<p><codeph>TKeyArrayVar</codeph> is used by the following functions accessible
through the <codeph>CArrayVarFlat</codeph> and <codeph>CArrayVarSeg</codeph> classes:</p>
<ul>
<li id="GUID-FDC42164-4F6A-59A4-8068-253E2D7B4702"><p><codeph>Sort()</codeph> </p> </li>
<li id="GUID-DF54D24C-B784-5297-8995-B9DFA228E773"><p><codeph>InsertIsqL()</codeph> </p> </li>
<li id="GUID-CC54EE8D-EA27-527A-B9CB-3BEA2D672547"><p><codeph>Find()</codeph>  </p> </li>
<li id="GUID-68A69B6F-1906-59C1-8502-74FAC80C2677"><p><codeph>FindIsq()</codeph> </p> </li>
</ul>
<p><codeph>TKeyArrayVar</codeph> is also used by <codeph>CArrayPakFlat::SortL()</codeph>.</p>
<p><codeph>TKeyArrayPak</codeph> is used by the following functions accessible
through the <codeph>CArrayPakFlat</codeph> class:</p>
<ul>
<li id="GUID-B180F59C-24BF-502B-BC94-2C1E67CB80DB"><p><codeph>InsertIsqL()</codeph> </p> </li>
<li id="GUID-E4023130-CE1E-5E46-90AC-76958E346424"><p><codeph>Find()</codeph>  </p> </li>
<li id="GUID-D31FCB05-78CB-51C5-8320-8B53362B83CD"><p><codeph>FindIsq()</codeph> </p> </li>
</ul>
<p>The concrete classes are all derived from the abstract base class <codeph>TKey</codeph> that
encapsulates the characteristics of a key and defines the basic behaviour
of keys. A class such as <codeph>TKeyArrayFix</codeph> provides an implementation
for specific arrays or types of array.</p>
<p>A key object is not a component of an array class but is constructed separately
and passed, as an argument, to the appropriate array class member function.
A key definition is not an integral part of an array, but is <i>used</i> by
an array.</p>
<p>A <codeph>TKey</codeph> derived object is also passed as an argument to
the <codeph>User::BinarySearch()</codeph> and <codeph>User::QuickSort()</codeph> functions.</p>
<p>An array can use various different key definitions during its life.</p>
<p>The characteristics of a key as defined by the base <codeph>TKey</codeph> class
are:</p>
<ul>
<li id="GUID-B73CBD70-BA02-55CF-915C-5E2CB5B1D2D3"><p>The type of data forming
the key.</p> </li>
<li id="GUID-0CD99B8B-0339-56F3-9ADA-888100D9EE05"><p>The type of comparison
to be made between two keys.</p> </li>
<li id="GUID-22BE001D-5C54-53C8-B4BE-7253182C5672"><p>The length of the key
within an array element.</p> </li>
<li id="GUID-394C8FE9-C9FB-593A-9A2B-6B682F0E8939"><p>The location of the
key within an array element.</p> </li>
</ul>
<p>See also:</p>
<ul>
<li id="GUID-3B74F364-852D-58E8-B24B-368290034A8C"><p><xref href="GUID-E3F403EE-717B-5EA6-BC4E-6840097CAC10.dita">Using
dynamic arrays</xref> </p> </li>
</ul>
</conbody></concept>