Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: e32std.h
Link against: euser.lib

Class TFixedArray

TFixedArray<class T,TInt S>

Support

Supported from 5.0

Description

A thin wrapper class for C++ arrays allowing automatic checking of index values to ensure that all accesses are legal. The class also provides support for the deletion of objects.

The class is templated, based on a class type and an integer value. The class type defines the type of object contained in the array; the integer value defines the size (dimension) of the array.

A wrapper object can be:

Defined in TFixedArray:
Array(), At(), Begin(), Copy(), Count(), DeleteAll(), End(), Length(), Reset(), TFixedArray(), operator[]


Construction


TFixedArray()

TFixedArray();

Description

Constructs an uninitialised C++ array.


TFixedArray()

TFixedArray(const T* aList, TInt aLength);

Description

Constructs a C++ array initialised with the specified objects.

Parameters

const T* aList

A pointer to a set of contiguous objects.

TInt aLength

The number of contiguous objects. This value must not be greater than the size of the array as defined by the integer template parameter. In a debug build only, this function raises a USER 133 panic, if this condition is not satisfied.

[Top]


Changing the content of the array


Copy()

void Copy(const T* aList, TInt aLength);

Description

Copies the specified set of contiguous objects into the C++ array. The copy operation starts at the beginning of the array, replacing any existing data.

Parameters

const T* aList

A pointer to a set of contiguous objects.

TInt aLength

The number of contiguous objects. This value must not be greater than the size of the array as defined by the integer template parameter. In a debug build only, this function raises a USER 133 panic, if this condition is not satisfied.


Reset()

void Reset();

Description

Fills every element of the array with binary zeroes.


DeleteAll()

void DeleteAll();

Description

Invokes the delete operator on every member of the array. The function can only be used for arrays of pointers to CBase derived objects.

If the array is to be used after a call to this function, it is good practice to call TFixedArray<class T,TInt S>::Reset() to set all array elements to NULL.

[Top]


Information about the array


Count()

TInt Count() const;

Description

Returns the size of the array. For any instance of this class, the array size is fixed and has the same value as the integer template parameter.

Return value

TInt

The size of the array


Length()

TInt Length() const;

Description

Returns the size of an array element, in bytes.

Return value

TInt

The size of an array element, in bytes.

[Top]


Accessing the array


At()

T& At(TInt aIndex);
const T& At(TInt aIndex) const;

Description

Returns a reference to the specified element within the C++ array checking that it is within the array in both release and debug builds.

The compiler chooses the appropriate function depending on the context of the call.

Parameters

TInt aIndex

The position of the element within the array. This is an offset; a zero value refers to the first element in the array. This value must be greater than or equal to zero and less than the size of the array, otherwise the function raises a USER 133 panic.

Return value

T&

A reference to an element of the array.

const T&

A reference to a const element of the array; the element cannot be changed through this reference.


operator[]

T& operator[](TInt aIndex);
const T& operator[] (TInt aIndex) const;

Description

Returns a reference to the specified element with the C++ array checking that it is within the array for debug builds only.

The compiler chooses the appropriate operator variant depending on the context of the call.

Parameters

TInt aIndex

The position of the element within the array. This is an offset; a zero value refers to the first element in the array. This value must be greater than or equal to zero and less than the size of the array. In a debug build only, the function raises a USER 133 panic if this condition is not satisfied.

Return value

T&

A reference to an element of the array.

const T&

A reference to a const element of the array; the element cannot be changed through this reference.


Begin()

T* Begin();
const T* Begin() const;

Description

Returns a pointer to the first element of the array.

The compiler chooses the appropriate function variant depending on the context of the call.

Return value

T*

A pointer to the first element of the array.

const T*

A pointer to a const element of the array; the element cannot be changed through this pointer.


End()

T* End();
const T* End() const;

Description

Returns a pointer to the first byte following the end of the array.

The compiler chooses the appropriate function variant depending on the context of the call.

Return value

T*

A pointer to the first byte following the end of the array.

const T*

A pointer to a const element of the array; the element cannot be changed through this pointer.

[Top]


Returning a generic array


Array()

TArray<T> Array() const;

Description

Creates and returns a generic array for this C++ array.

Return value

TArray<T>

A generic array for this C++ array.