CArrayPak Class Reference

#include <e32base.h>

class CArrayPak : public CArrayPakBase

Inherits from

Public Member Functions
CArrayPak(TBufRep, TInt)
voidAppendL(const T &, TInt)
const TArray< T >Array()
const T &At(TInt)
T &At(TInt)
T &ExpandL(TInt, TInt)
T &ExtendL(TInt)
TInt Find(const T &, TKeyArrayPak &, TInt &)
TInt FindIsq(const T &, TKeyArrayPak &, TInt &)
TInt InsertIsqAllowDuplicatesL(const T &, TInt, TKeyArrayPak &)
TInt InsertIsqL(const T &, TInt, TKeyArrayPak &)
voidInsertL(TInt, const T &, TInt)
const T &operator[](TInt)
T &operator[](TInt)
Inherited Functions
CArrayPakBase::AtR(const CBase *,TInt)
CArrayPakBase::BuildVarArrayL(CArrayVarFlat< TAny > *&)
CArrayPakBase::CArrayPakBase(TBufRep,TInt)
CArrayPakBase::Compress()
CArrayPakBase::Count()const
CArrayPakBase::CountR(const CBase *)
CArrayPakBase::Delete(TInt)
CArrayPakBase::Delete(TInt,TInt)
CArrayPakBase::Find(const TAny *,TKeyArrayPak &,TInt &)const
CArrayPakBase::FindIsq(const TAny *,TKeyArrayPak &,TInt &)const
CArrayPakBase::GetOffset(TInt)const
CArrayPakBase::InsertIsqAllowDuplicatesL(const TAny *,TInt,TKeyArrayPak &)
CArrayPakBase::InsertIsqL(const TAny *,TInt,TKeyArrayPak &)
CArrayPakBase::InsertL(TInt,const TAny *,TInt)
CArrayPakBase::Length(TInt)const
CArrayPakBase::Reset()
CArrayPakBase::SetKey(TKeyArrayPak &)const
CArrayPakBase::SortL(TKeyArrayVar &)
CArrayPakBase::~CArrayPakBase()
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 variable length, packed, arrays.

The public functions provide standard array behaviour.

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

Constructor & Destructor Documentation

CArrayPak ( TBufRep, TInt )

CArrayPak(TBufRepaRep,
TIntaGranularity
)[inline]

Member Function Documentation

AppendL ( const T &, TInt )

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

Appends an element of a specified length onto the array.

Parameters
aRefA reference to the class T element to be appended.
aLengthThe length of the element to be appended.
Leave Codes
KErrNoMemoryThe function attempted to allocate from the heap and there is insufficient memory available. In this case, the array is left in the state it was in before the call.
Panic Codes
E32USER-CBase30, if aLength is negative.

Array ( )

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

Constructs and returns a TArray<T> object.

Return Value
A Tarray<T> object for this array.

At ( TInt )

const T &At(TIntanIndex)const [inline]

Reimplemented from CArrayPakBase::At(TInt)const

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

The compiler uses this variant of the function when the returned reference is used in an expression where it cannot be modified.

Parameters
anIndexThe position of the element within the array. The position is relative to zero; i.e. zero implies the first element in the array.
Return Value
A const reference to the element located at position anIndex within the array.
Panic Codes
E32USER-CBase21, if anIndex is negative or greater than or equal to number of objects currently within the array.

At ( TInt )

T &At(TIntanIndex)[inline]

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

The compiler uses this variant of the function when the returned reference is used in an expression where it can be modified.

Parameters
anIndexThe position of the element within the array. The position is relative to zero; i.e. zero implies the first element in the array.
Return Value
A non-const reference to the element located at position anIndex within the array.
Panic Codes
E32USER-CBase21, if anIndex is negative or greater than or equal to number of objects currently within the array.

ExpandL ( TInt, TInt )

T &ExpandL(TIntanIndex,
TIntaLength
)[inline]

Expands the array by one element of specified length at the specified position.

It:

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

2. constructs a new element of specified length 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>=""> and length aLength is constructed at position anIndex, using the default constructor of that class.

Parameters
anIndexThe position within the array where the array is to be expanded and the new <class t>=""> object is to be constructed.
aLengthThe length of the new element.
Return Value
A reference to the newly constructed <class t>=""> object at position anIndex within the array.
Leave Codes
KErrNoMemoryThe function attempted to allocate from the heap and there is insufficient memory available. In this case, the array is left in the state it was in before the call.
Panic Codes
E32USER-CBase21, if anIndex is negative or greater than the number of elements currently in the array.
E32USER-CBase30, if aLength is negative.

ExtendL ( TInt )

T &ExtendL(TIntaLength)[inline]

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

It:

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

2. constructs a new element of length aLength 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.

Parameters
aLengthThe length of the new element.
Return Value
A reference to the newly constructed <class t>=""> object at the end of the array.
Leave Codes
KErrNoMemoryThe function attempted to allocate from the heap and there is insufficient memory available. In this case, the array is left in the state it was in before the call.
Panic Codes
E32USER-CBase30, if aLength is negative.

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

TInt Find(const T &aRef,
TKeyArrayPak &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.

Parameters
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, this 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 or the array is empty, then this is undefined.
Return Value
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 &, TKeyArrayPak &, TInt & )

TInt FindIsq(const T &aRef,
TKeyArrayPak &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.

Parameters
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, this 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 this 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 this is undefined.
Return Value
Zero, if the element with the specified key is found or the array is empty. Non-zero, if the element with the specified key is not found.

InsertIsqAllowDuplicatesL ( const T &, TInt, TKeyArrayPak & )

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

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

The array MUST already be in key sequence, otherwise the position of the new element is unpredictable.

Elements with duplicate keys are permitted. 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.

Parameters
aRefA reference to the element of type <class t>=""> to be inserted into the array.
aLengthThe length of the new element to be inserted into the array.
aKeyA reference to a key object defining the properties of the key.
Return Value
The position within the array of the newly inserted element.
Leave Codes
KErrNoMemoryThe function attempted to expand the array buffer and there is insufficient memory available. In this case, the array is left in the state it was in before the call.

InsertIsqL ( const T &, TInt, TKeyArrayPak & )

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

Inserts a single element of a specified length 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.

Parameters
aRefA reference to the element of type <class t>=""> to be inserted into the array.
aLengthThe length of the new element of type <class t>=""> to be inserted into the array.
aKeyA reference to a key object defining the properties of the key.
Return Value
The position within the array of the newly inserted element.
Leave Codes
KErrAlreadyExistsAn 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.
KErrNoMemoryThe function attempted to expand the array buffer and there is insufficient memory available. In this case, the array is left in the state it was in before the call.

InsertL ( TInt, const T &, TInt )

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

Inserts an element of a specified length into the array at the specified position.

Parameters
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.
aLengthThe length of the element to be inserted into the array.
Leave Codes
KErrNoMemoryThe function attempted to expand the array buffer and there is insufficient memory available. In this case, the array is left in the state it was in before the call.
Panic Codes
E32USER-CBase21, if anIndex is negative or greater than the number of objects currently in the array.
E32USER-CBase30, if aLength is negative.

operator[] ( TInt )

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

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

The compiler uses this variant of the function when the returned reference is used in an expression where it cannot be modified.

Parameters
anIndexThe position of the element within the array. The position is relative to zero; i.e. zero implies the first element in the array.
Return Value
A const reference to the element located at position anIndex within the array.
Panic Codes
E32USER-CBase21, if anIndex is negative or greater than or equal to number of objects currently within the array.

operator[] ( TInt )

T &operator[](TIntanIndex)[inline]

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

The compiler uses this variant of the function when the returned reference is used in an expression where it can be modified.

Parameters
anIndexThe position of the element within the array. The position is relative to zero; i.e. zero implies the first element in the array.
Return Value
A non-const reference to the element located at position anIndex within the array.
Panic Codes
E32USER-CBase21, if anIndex is negative or greater than or equal to number of objects currently within the array.