CArrayFix Class Reference

#include <e32base.h>

Link against: eposprvtyp.lib

class CArrayFix : public CArrayFixBase

Inherits from

Public Member Functions
CArrayFix(TBufRep, TInt)
voidAppendL(const T &)
voidAppendL(const T *, TInt)
voidAppendL(const T &, TInt)
const TArray< T >Array()
const T &At(TInt)
T &At(TInt)
const T *Back(TInt)
T *Back(TInt)
const T *End(TInt)
T *End(TInt)
T &ExpandL(TInt)
T &ExtendL()
TInt Find(const T &, TKeyArrayFix &, TInt &)
TInt FindIsq(const T &, TKeyArrayFix &, TInt &)
TInt InsertIsqAllowDuplicatesL(const T &, TKeyArrayFix &)
TInt InsertIsqL(const T &, TKeyArrayFix &)
voidInsertL(TInt, const T &)
voidInsertL(TInt, const T *, TInt)
voidInsertL(TInt, const T &, TInt)
voidResizeL(TInt)
voidResizeL(TInt, const T &)
const T &operator[](TInt)
T &operator[](TInt)
Inherited Functions
CArrayFixBase::AtR(const CBase *,TInt)
CArrayFixBase::CArrayFixBase(TBufRep,TInt,TInt)
CArrayFixBase::Compress()
CArrayFixBase::Count()const
CArrayFixBase::CountR(const CBase *)
CArrayFixBase::Delete(TInt)
CArrayFixBase::Delete(TInt,TInt)
CArrayFixBase::Find(const TAny *,TKeyArrayFix &,TInt &)const
CArrayFixBase::FindIsq(const TAny *,TKeyArrayFix &,TInt &)const
CArrayFixBase::InsertIsqAllowDuplicatesL(const TAny *,TKeyArrayFix &)
CArrayFixBase::InsertIsqL(const TAny *,TKeyArrayFix &)
CArrayFixBase::InsertL(TInt,const TAny *)
CArrayFixBase::InsertL(TInt,const TAny *,TInt)
CArrayFixBase::InsertRepL(TInt,const TAny *,TInt)
CArrayFixBase::Length()const
CArrayFixBase::Reset()
CArrayFixBase::ResizeL(TInt,const TAny *)
CArrayFixBase::SetKey(TKeyArrayFix &)const
CArrayFixBase::SetReserveFlatL(TInt)
CArrayFixBase::Sort(TKeyArrayFix &)
CArrayFixBase::~CArrayFixBase()
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()

Detailed Description

A thin templated base class for arrays of fixed length objects.

The public functions provide standard array behaviour.

The class is always derived from and is never instantiated explicitly.

Constructor & Destructor Documentation

CArrayFix ( TBufRep, TInt )

CArrayFix(TBufRepaRep,
TIntaGranularity
)[inline]

Member Function Documentation

AppendL ( const T & )

voidAppendL(const T &aRef)[inline]

Appends a single element onto the end of the array.

leave
KErrNoMemory The function may attempt to expand the array buffer. If there is insufficient memory available, the function leaves, in which case the array is left in the state it was in before the call.
ParameterDescription
aRefA reference to the class T element to be appended.

AppendL ( const T *, TInt )

voidAppendL(const T *aPtr,
TIntaCount
)[inline]

Appends one or more elements onto the end of the array.

leave
KErrNoMemory The function may attempt to expand the array buffer. If there is insufficient memory available, the function leaves, in which case the array is left in the state it was in before the call.
panic
E32USER-CBase 23, if aCount is negative.
ParameterDescription
aPtrA pointer to a contiguous set of type <class T> objects to be appended.
aCountThe number of contiguous objects of type <class T> located at aPtr to be appended.

AppendL ( const T &, TInt )

voidAppendL(const T &aRef,
TIntaReplicas
)[inline]

Appends replicated copies of an element onto the end of the array.

leave
KErrNoMemory The function may attempt to expand the array buffer. If there is insufficient memory available, the function leaves, in which case the array is left in the state it was in before the call.
panic
E32USER-CBase 28 if aReplicas is negative.
ParameterDescription
aRefA reference to the <class T> object to be replicated and appended.
aReplicasThe number of copies of the aRef element to be appended.

Array ( )

const TArray< T >Array()const [inline]

Constructs and returns a TArray<T> object.

Returns: A TArray<T> object representing this array.

At ( TInt )

const T &At(TIntanIndex)const [inline]

Reimplemented from CArrayFixBase::At(TInt)const

Gets a const reference to the element located at the specified position within the array.

Note that if a pointer to the returned referenced class T object is taken, be aware that the pointer value becomes invalid once elements have been added to, or removed from the array. Always refresh the pointer.

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. The position is relative to zero; i.e. zero implies the first element in the array.

Returns: A const reference to the required element.

At ( TInt )

T &At(TIntanIndex)[inline]

Gets a non-const reference to the element located at the specified position within the array.

Note that if a pointer to the returned referenced class T object is taken, be aware that the pointer value becomes invalid once elements have been added to, or removed from the array. Always refresh the pointer.

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. The position is relative to zero; i.e. zero implies the first element in the array.

Returns: A non-const reference to the required element.

Back ( TInt )

const T *Back(TIntanIndex)const [inline]

Gets a pointer to the (const) beginning of a contiguous region.

For arrays implemented using flat buffers, the function always returns a pointer to the beginning of the buffer.

For arrays implemented using segmented buffers, the function returns a pointer to the beginning of the segment for all elements in that segment except the first. If the element at position anIndex is the first in a segment, then the function returns a pointer the beginning of the previous segment.

For the first element in the array, the function returns a NULL pointer.

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. The position is relative to zero; i.e. zero implies the first element in the array.

Returns: A pointer to the (const) beginning of the contiguous region.

Back ( TInt )

T *Back(TIntanIndex)[inline]

Gets a pointer to the beginning of a contiguous region.

For arrays implemented using flat buffers, the function always returns a pointer to the beginning of the buffer.

For arrays implemented using segmented buffers, the function returns a pointer to the beginning of the segment for all elements in that segment except the first. If the element at position anIndex is the first in a segment, then the function returns a pointer the beginning of the previous segment.

For the first element in the array, the function returns a NULL pointer.

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. The position is relative to zero; i.e. zero implies the first element in the array.

Returns: A pointer to the beginning of the contiguous region.

End ( TInt )

const T *End(TIntanIndex)const [inline]

Gets a pointer to the (const) first byte following the end of the contiguous region containing the element at the specified position within the array.

For arrays implemented using flat buffers, the pointer always points to the first byte following the end of the buffer.

For arrays implemented using segmented buffers, the pointer always points to the first byte following the end of the segment which contains the element.

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. The position is relative to zero; i.e. zero implies the first element in the array.

Returns: A pointer to the constant byte following the end of the contiguous region.

End ( TInt )

T *End(TIntanIndex)[inline]

Gets a pointer to the first byte following the end of the contiguous region containing the element at the specified position within the array.

For arrays implemented using flat buffers, the pointer always points to the first byte following the end of the buffer.

For arrays implemented using segmented buffers, the pointer always points to the first byte following the end of the segment which contains the element.

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. The position is relative to zero; i.e. zero implies the first element in the array.

Returns: A pointer to the byte following the end of the contiguous region.

ExpandL ( TInt )

T &ExpandL(TIntanIndex)[inline]

Reimplemented from CArrayFixBase::ExpandL(TInt)

Expands the array by one element at the specified position.

It:

1. expands the array by one element at the specified position

2. constructs a new element at that position

3. returns a reference to the new element.

All existing elements from position anIndex to the end of the array are moved up, so that the element originally at position anIndex is now at position anIndex + 1 etc.

The new element of type class T is constructed at position anIndex, using the default constructor of that class.

leave
KErrNoMemory The function may attempt to expand the array buffer. If there is insufficient memory available, the function leaves, in which case the array is left in the state it was in before the call.
panic
E32USER-CBase 21 if anIndex is negative or greater than the number of elements currently in the array.
ParameterDescription
anIndexThe position within the array where the array is to be expanded and the new class T object is to be constructed.

Returns: A reference to the newly constructed class T object at position anIndex within the array.

ExtendL ( )

T &ExtendL()[inline]

Expands the array by one element at the end of the array.

It:

1. expands the array by one element at the end of the array, i.e. at position CArrayFixBase::Count()

2. constructs a new element at that position

3. returns a reference to the new element.

The new element of type class T is constructed at the end of the array, using the default constructor of that class.

leave
KErrNoMemory The function may attempt to expand the array buffer. If there is insufficient memory available, the function leaves, in which case the array is left in the state it was in before the call.

See also: CArrayFixBase::Count

Returns: A reference to the newly constructed class T object at the end of the array.

Find ( const T &, TKeyArrayFix &, TInt & )

TInt Find(const T &aRef,
TKeyArrayFix &aKey,
TInt &anIndex
)const [inline]

Finds the position of an element within the array, based on the matching of keys, using a sequential search.

The array is searched sequentially for an element whose key matches the key of the supplied class T object. The search starts with the first element in the array.

Note that where an array has elements with duplicate keys, the function only supplies the position of the first element in the array with that key.

ParameterDescription
aRefA reference to an object of type class T whose key is used for comparison.
aKeyA reference to a key object defining the properties of the key.
anIndexA reference to a TInt supplied by the caller. On return, if the element is found, the reference is set to the position of that element within the array. The position is relative to zero, (i.e. the first element in the array is at position 0). If the element is not found and the array is not empty, then the value of the reference is set to the number of elements in the array. If the element is not found and the array is empty, then the reference is set to zero.

Returns: Zero, if the element with the specified key is found. Non-zero, if the element with the specified key is not found.

FindIsq ( const T &, TKeyArrayFix &, TInt & )

TInt FindIsq(const T &aRef,
TKeyArrayFix &aKey,
TInt &anIndex
)const [inline]

Finds the position of an element within the array, based on the matching of keys, using a binary search technique.

The array is searched, using a binary search technique, for an element whose key matches the key of the supplied class T object.

The array must be in key order.

Note that where an array has elements with duplicate keys, the function cannot guarantee which element, with the given key value, it will return, except that it will find one of them.

ParameterDescription
aRefA reference to an object of type class T whose key is used for comparison.
aKeyA reference to a key object defining the properties of the key.
anIndexA reference to a TInt supplied by the caller. On return, if the element is found, the reference is set to the position of that element within the array. The position is relative to zero, (i.e. the first element in the array is at position 0). If the element is not found and the array is not empty, then the reference is set to the position of the first element in the array with a key which is greater than the key of the object aRef. If the element is not found and the array is empty, then the reference is set to zero.

Returns: Zero, if the element with the specified key is found. Non-zero, if the element with the specified key is not found.

InsertIsqAllowDuplicatesL ( const T &, TKeyArrayFix & )

TInt InsertIsqAllowDuplicatesL(const T &aRef,
TKeyArrayFix &aKey
)[inline]

Inserts a single element into the array at a position determined by a key, allowing duplicates.

The array MUST already be in key sequence (as defined by the key), otherwise the position of the new element is unpredictable.

If the new element's key is a duplicate of an existing element's key, then the new element is positioned after the existing element.

leave
KErrNoMemory The function may attempt to expand the array buffer. If there is insufficient memory available, the function leaves, in which case the array is left in the state it was in before the call.
ParameterDescription
aRefA reference to the element of type <class T> to be inserted into the array.
aKeyA reference to a key object defining the properties of the key.

Returns: The position within the array of the newly inserted element.

InsertIsqL ( const T &, TKeyArrayFix & )

TInt InsertIsqL(const T &aRef,
TKeyArrayFix &aKey
)[inline]

Inserts a single element into the array at a position determined by a key.

The array MUST already be in key sequence (as defined by the key), otherwise the position of the new element is unpredictable, or duplicates may occur.

Elements with duplicate keys are not permitted.

leave
KErrAlreadyExists An element with the same key already exists within the array. NB the array MUST already be in key sequence, otherwise the function may insert a duplicate and fail to leave with this value.
leave
KErrNoMemory The function may attempt to expand the array buffer. If there is insufficient memory available, the function leaves, in which case the array is left in the state it was in before the call.
ParameterDescription
aRefA reference to the element of type <class T> to be inserted into the array.
aKeyA reference to a key object defining the properties of the key.

Returns: The position within the array of the newly inserted element.

InsertL ( TInt, const T & )

voidInsertL(TIntanIndex,
const T &aRef
)[inline]

Inserts an element into the array at the specified position.

Note that passing a value of anIndex which is the same as the current number of elements in the array, has the effect of appending the element.

leave
KErrNoMemory The function may attempt to expand the array buffer. If there is insufficient memory available, the function leaves, in which case the array is left in the state it was in before the call.
panic
E32USER-CBase 21 if anIndex is negative, or is greater than the number of elements currently in the array.
ParameterDescription
anIndexThe position within the array where the element is to be inserted. The position is relative to zero, i.e. zero implies that elements are inserted at the beginning of the array.
aRefA reference to the class T object to be inserted into the array at position anIndex.

InsertL ( TInt, const T *, TInt )

voidInsertL(TIntanIndex,
const T *aPtr,
TIntaCount
)[inline]

Inserts one or more elements into the array at the specified position.

The objects to be added must all be contiguous.

Note that passing a value of anIndex which is the same as the current number of elements in the array, has the effect of appending the element.

leave
KErrNoMemory The function may attempt to expand the array buffer. If there is insufficient memory available, the function leaves, in which case the array is left in the state it was in before the call.
panic
E32USER-CBase 21 if anIndex is negative or is greater than the number of elements currently in the array.
panic
E32USER-CBase 23 if aCount is negative.
ParameterDescription
anIndexThe position within the array where the elements are to be inserted. The position is relative to zero, i.e. zero implies that elements are inserted at the beginning of the array.
aPtrA pointer to the first of the contiguous elements of type class T to be inserted into the array at position anIndex.
aCountThe number of contiguous elements of type class T located at aPtr to be inserted into the array.

InsertL ( TInt, const T &, TInt )

voidInsertL(TIntanIndex,
const T &aRef,
TIntaReplicas
)[inline]

Inserts replicated copies of an element into the array at the specified position.

Note that passing a value of anIndex which is the same as the current number of elements in the array, has the effect of appending the element.

leave
KErrNoMemory The function may attempt to expand the array buffer. If there is insufficient memory available, the function leaves, in which case the array is left in the state it was in before the call.
panic
E32USER-CBase 21, if anIndex is negative or is greater than the number of elements currently in the array.
panic
E32USER-CBase 28, if aReplicas is negative.
ParameterDescription
anIndexThe position within the array where elements are to be inserted. The position is relative to zero, i.e. zero implies that elements are inserted at the beginning of the array.
aRefA reference to the class T object to be replicated and inserted into the array at position anIndex.
aReplicasThe number of copies of the aRef element to be inserted into the array.

ResizeL ( TInt )

voidResizeL(TIntaCount)[inline]

Changes the size of the array so that it contains the specified number of elements.

The following describes the effects of calling this function:

1. If aCount is less than the current number of elements in the array, then the array is shrunk. The elements at positions aCount and above are discarded. The array buffer is not compressed.

2. If aCount is greater than the current number of elements in the array, then the array is extended.

3. New elements are replicated copies of an object of type <class T>, constructed using the default constructor of that class.

The new elements are positioned after the existing elements in the array.

The function may attempt to expand the array buffer. If there is insufficient memory available, the function leaves. The leave code is one of the system wide error codes. If the function leaves, the array is left in the state it was in before the call.

panic
E32USER-CBase 24, if aCount is negative.
ParameterDescription
aCountThe number of elements the array is to contain after the resizing operation.

ResizeL ( TInt, const T & )

voidResizeL(TIntaCount,
const T &aRef
)[inline]

Changes the size of the array so that it contains the specified number of elements.

The following describes the effects of calling this function:

1. If aCount is less than the current number of elements in the array, then the array is shrunk. The elements at positions aCount and above are discarded. The array buffer is not compressed.

2. If aCount is greater than the current number of elements in the array, then the array is extended.

3. New elements are replicated copies of aRef.

The new elements are positioned after the existing elements in the array.

The function may attempt to expand the array buffer. If there is insufficient memory available, the function leaves. The leave code is one of the system wide error codes. If the function leaves, the array is left in the state it was in before the call.

panic
E32USER-CBase 24, if aCount is negative.
ParameterDescription
aCountThe number of elements the array is to contain after the resizing operation.
aRefA reference to an object of type <class T>, copies of which are used as the new elements of the array, if the array is extended.

operator[] ( TInt )

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

Gets a const reference to the element located at the specified position within the array.

Note that if a pointer to the returned referenced class T object is taken, be aware that the pointer value becomes invalid once elements have been added to, or removed from the array. Always refresh the pointer.

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. The position is relative to zero; i.e. zero implies the first element in the array.

Returns: A const reference to the required element.

operator[] ( TInt )

T &operator[](TIntanIndex)[inline]

Gets a non-const reference to the element located at the specified position within the array.

Note that if a pointer to the returned referenced class T object is taken, be aware that the pointer value becomes invalid once elements have been added to, or removed from the array. Always refresh the pointer.

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. The position is relative to zero; i.e. zero implies the first element in the array.

Returns: A non-const reference to the required element.