This document provides an introduction to array keys.
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.
The characteristics of a key are defined by a key object, constructed from one of the three concrete classes: TKeyArrayFix, TKeyArrayVar and TKeyArrayPak. In general, the choice of key class depends on the type of array being used and the specific member function of that array.
TKeyArrayFix is used by the following functions accessible through the CArrayFixFlat and CArrayFixSeg classes:
TKeyArrayVar is used by the following functions accessible through the CArrayVarFlat and CArrayVarSeg classes:
TKeyArrayVar is also used by CArrayPakFlat::SortL().
TKeyArrayPak is used by the following functions accessible through the CArrayPakFlat class:
The concrete classes are all derived from the abstract base class TKey that encapsulates the characteristics of a key and defines the basic behaviour of keys. A class such as TKeyArrayFix provides an implementation for specific arrays or types of array.
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 used by an array.
A TKey derived object is also passed as an argument to the User::BinarySearch() and User::QuickSort() functions.
An array can use various different key definitions during its life.
The characteristics of a key as defined by the base TKey class are:
The type of data forming the key.
The type of comparison to be made between two keys.
The length of the key within an array element.
The location of the key within an array element.
See also: