TArray Class Reference

#include <e32cmn.h>

Link against: eposprvtyp.lib

class TArray
Public Member Functions
TArray(TInt(*)(const CBase *aPtr), const TAny *(*)(const CBase *aPtr, TInt anIndex), const CBase *)
TInt Count()
const T &operator[](TInt)

Detailed Description

Generic array.

This class defines a generic array which can be constructed by any of the following templated concrete arrays:

1. CArrayFixFlat<class T>

2. CArrayFixSeg<class T>

3. CArrayVarFlat<class T>

4. CArrayVarSeg<class T>

5. CArrayPakFlat<class T>

6. RArray<class T>

7. RPointerArray<class T>

and also by the following template specialisation classes:

1. RArray<TInt>

2. RArray<TUint>

It allows a degree of polymorphism amongst the array classes. It permits the operator[] and the Count() member functions of an array to be invoked without knowing which array class has been used to construct that array.

TArray allows access to elements of an array but does not permit changes to those elements.

Use the Array() member function of an array to construct and return a TArray<class T> object for that array.

A TArray<class T> type object is not intended to be constructed explicitly by user code.

See also: CArrayFixFlat CArrayFixSeg CArrayVarFlat CArrayVarSeg CArrayPakFlat RArray RPointerArray RArray<TInt> RArray<TUint>

Constructor & Destructor Documentation

TArray ( TInt(*)(const CBase *aPtr), const TAny *(*)(const CBase *aPtr, TInt anIndex), const CBase * )

TArray(TInt(*)(const CBase *aPtr)aCount,
const TAny *(*)(const CBase *aPtr, TInt anIndex)anAt,
const CBase *aPtr
)[inline]

Constructor.

A TArray object is not intended to be instantiated explicitly. An object of this type is instantiated as a result of a call to to the Array() member function of a concrete array class

See also: CArrayFixFlat::Array CArrayFixSeg::Array CArrayVarFlat::Array CArrayVarSeg::Array CArrayPakFlat::Array RArray::Array RPointerArray::Array RArray<TInt>::Array RArray<TUint>::Array

ParameterDescription
aCountA pointer to a function which takes a const CBase* argument and returns a TInt aCount must point to the member function which returns the current number of elements of type class T contained in the array at aPtr, for which this TArray is being constructed. This argument is supplied by the Array() member function of the array class.
anAtA pointer to a function which takes a const CBase* and a TInt argument, and returns a pointer to TAny anAt must point to the member function which returns a reference to the element located at position anIndex within the array at aPtr, for which this TArray is being constructed. This argument is supplied by the Array() member function of the array class.
aPtrA pointer to the array for which this TArray is being constructed. This argument is supplied by the Array() member function of the array class.

Member Function Documentation

Count ( )

TInt Count()const [inline]

Gets the number of elements currently held in the array for which this generic array has been constructed.

Returns: The number of array elements.

operator[] ( TInt )

const T &operator[](TIntanIndex)const [inline]

Gets a reference to the element located at the specified position.

The returned reference is const and cannot be used to change the element. Any member function of the referenced template class T must be declared as const if that function is to be accessed through this operator.

panic
E32USER-CBase 21, if anIndex is negative, or greater than or equal to the number of objects currently within the array.
ParameterDescription
anIndexThe position of the element within the array for which this TArray has been constructed. The position is relative to zero; i.e. zero implies the first element in the array.

Returns: A const reference to the element located at position anIndex within the array for which this TArray has been constructed.