Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

#include <e32cmn.h>

Class TArray

class TArray;

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 TArray::Count()const 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.

Members

Defined in TArray:

See also:


Construction and destruction


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

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

Description

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

Parameters

TInt(*)(const CBase *aPtr) aCount

A pointer to a function which takes a argument and returns a 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.

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

A pointer to a function which takes a and a argument, and returns a pointer to 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.

const CBase *aPtr

A pointer to the array for which this TArray is being constructed. This argument is supplied by the Array() member function of the array class.

See also:

[Top]


Member functions


Count()const

inline TInt Count() const;

Description

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

Return value

TInt

The number of array elements.


operator[](TInt)const

inline const T& operator[](TInt anIndex) const;

Description

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.

Parameters

TInt anIndex

The 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.

Return value

const T &

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

Panic codes

E32USER-CBase

21, if anIndex is negative, or greater than or equal to the number of objects currently within the array.