Symbian3/SDK/Source/GUID-07FA8EC8-151F-574A-89F2-34C4AE2D1F0B.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-07FA8EC8-151F-574A-89F2-34C4AE2D1F0B" xml:lang="en"><title>How
to find elements</title><shortdesc>There are two methods for searching for data in an array. Sequentially
and binary chop.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>A search can be made for elements based on the value of a key. A search
can be done in one of two ways: </p>
<ul>
<li id="GUID-1C8D05FB-E5CA-5237-9666-CE4EF72A0920"><p>Sequentially through
the array, starting with the first element — performed using the <codeph>Find()</codeph> member
function</p> </li>
<li id="GUID-B4727A94-2FA9-5F98-B0E2-DA63AF73191B"><p>Using a binary search
(binary chop) technique — performed using the <codeph>FindIsq()</codeph> member
function. This technique assumes that the array elements are in key sequence.</p> </li>
</ul>
<p>Both functions indicate the success or failure of the search and, if successful,
supply the position of the element within the array.</p>
<p>Note that where an array has elements with <i>duplicate keys</i>:</p>
<ul>
<li id="GUID-EB9FCE02-B203-525D-AED7-5D5E6E2E054C"><p><codeph>Find()</codeph> only
supplies the position of the <i>first</i> element in the array with that key.</p> </li>
<li id="GUID-B084BCB6-18C7-5EE1-8184-AB17A525967F"><p><codeph>FindIsq()</codeph> cannot
guarantee which element, with the given key value, it will return; except
that it will find one of them.</p> </li>
</ul>
<p>The elements of arrays can be sorted. This is done by the <codeph>Sort()</codeph> member
function for <codeph>CArrayFixFlat&lt;class T&gt;</codeph>, <codeph>CArrayFixSeg&lt;class T&gt;</codeph>, <codeph>CArrayVarFlat&lt;class T&gt;</codeph> and <codeph>CArrayVarSeg&lt;class T&gt;</codeph> arrays. You must use the <codeph>SortL()</codeph> member
function for the <codeph>CArrayPakFlat&lt;class T&gt;</codeph> array. </p>
</conbody></concept>