Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
<?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<class T></codeph>, <codeph>CArrayFixSeg<class T></codeph>, <codeph>CArrayVarFlat<class T></codeph> and <codeph>CArrayVarSeg<class T></codeph> arrays. You must use the <codeph>SortL()</codeph> member
function for the <codeph>CArrayPakFlat<class T></codeph> array. </p>
</conbody></concept>