TKey Class Reference

class TKey

Defines the characteristics of a key used to access the elements of an array.

The class is abstract and cannot be instantiated. A derived class must be defined and implemented.

The classes TKeyArrayFix, TKeyArrayVar and TKeyArrayPak, derived from TKey, are already supplied to implement keys for the fixed length element, variable length element and packed arrays.

A derived class would normally be written to define the characteristics of a key for a non standard array.

TKeyArrayFix

TKeyArrayVar

TKeyArrayPak

Public Member Functions
IMPORT_C TAny *At(TInt)
IMPORT_C TIntCompare(TInt, TInt)
voidSetPtr(const TAny *)
Protected Member Functions
TKey()
TKey(TInt, TKeyCmpText)
TKey(TInt, TKeyCmpText, TInt)
TKey(TInt, TKeyCmpNumeric)
Protected Attributes
TInt iCmpType
TInt iKeyLength
TInt iKeyOffset
const TAny *iPtr

Constructor & Destructor Documentation

TKey()

IMPORT_CTKey()[protected]

TKey(TInt, TKeyCmpText)

IMPORT_CTKey(TIntaOffset,
TKeyCmpTextaType
)[protected]

Parameters

TInt aOffset
TKeyCmpText aType

TKey(TInt, TKeyCmpText, TInt)

IMPORT_CTKey(TIntaOffset,
TKeyCmpTextaType,
TIntaLength
)[protected]

Parameters

TInt aOffset
TKeyCmpText aType
TInt aLength

TKey(TInt, TKeyCmpNumeric)

IMPORT_CTKey(TIntaOffset,
TKeyCmpNumericaType
)[protected]

Parameters

TInt aOffset
TKeyCmpNumeric aType

Member Functions Documentation

At(TInt)

IMPORT_C TAny *At(TIntanIndex)const [virtual]

Parameters

TInt anIndex

Compare(TInt, TInt)

IMPORT_C TIntCompare(TIntaLeft,
TIntaRight
)const [virtual]

Parameters

TInt aLeft
TInt aRight

SetPtr(const TAny *)

voidSetPtr(const TAny *aPtr)[inline]

Sets the pointer to a sample element whose key is to be used for comparison.

The element can be in an existing array or it can be located anywhere in addressable memory.

The At() member function supplied by a derived class must return a pointer to this sample element's key when passed an index value of KIndexPtr.

SetPtr() must be called before calling User::BinarySearch() because this algorithm uses the key of this sample element as the basis for searching the array.

Parameters

const TAny * aPtrA pointer to a sample element.

Member Data Documentation

TInt iCmpType

TInt iCmpType[protected]

TInt iKeyLength

TInt iKeyLength[protected]

TInt iKeyOffset

TInt iKeyOffset[protected]

const TAny * iPtr

const TAny *iPtr[protected]