Original Symbian headers
Selected EUSER, Window Server, networking, graphics and device declarations
Loading...
Searching...
No Matches
CArrayFix< T > Class Template Reference

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

#include <e32base.h>

Inheritance diagram for CArrayFix< T >:
CArrayFixBase CBase CArrayFixFlat< TFileEntry > CArrayFixFlat< HBufC * > CArrayFixFlat< TFontAccess > CArrayFixSeg< TModelEntry > CArrayFixFlat< T > CArrayFixSeg< T >

Public Member Functions

 CArrayFix (TBufRep aRep, TInt aGranularity)
 
const T & operator[] (TInt anIndex) const
 Gets a const reference to the element located at the specified position within the array.
 
T & operator[] (TInt anIndex)
 Gets a non-const reference to the element located at the specified position within the array.
 
const T & At (TInt anIndex) const
 Gets a const reference to the element located at the specified position within the array.
 
const T * End (TInt anIndex) const
 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.
 
const T * Back (TInt anIndex) const
 Gets a pointer to the (const) beginning of a contiguous region.
 
T & At (TInt anIndex)
 Gets a non-const reference to the element located at the specified position within the array.
 
T * End (TInt anIndex)
 Gets a pointer to the first byte following the end of the contiguous region containing the element at the specified position within the array.
 
T * Back (TInt anIndex)
 Gets a pointer to the beginning of a contiguous region.
 
void AppendL (const T &aRef)
 Appends a single element onto the end of the array.
 
void AppendL (const T *aPtr, TInt aCount)
 Appends one or more elements onto the end of the array.
 
void AppendL (const T &aRef, TInt aReplicas)
 Appends replicated copies of an element onto the end of the array.
 
T & ExpandL (TInt anIndex)
 Expands the array by one element at the specified position.
 
T & ExtendL ()
 Expands the array by one element at the end of the array.
 
TInt Find (const T &aRef, TKeyArrayFix &aKey, TInt &anIndex) const
 Finds the position of an element within the array, based on the matching of keys, using a sequential search.
 
TInt FindIsq (const T &aRef, TKeyArrayFix &aKey, TInt &anIndex) const
 Finds the position of an element within the array, based on the matching of keys, using a binary search technique.
 
void InsertL (TInt anIndex, const T &aRef)
 Inserts an element into the array at the specified position.
 
void InsertL (TInt anIndex, const T *aPtr, TInt aCount)
 Inserts one or more elements into the array at the specified position.
 
void InsertL (TInt anIndex, const T &aRef, TInt aReplicas)
 Inserts replicated copies of an element into the array at the specified position.
 
TInt InsertIsqL (const T &aRef, TKeyArrayFix &aKey)
 Inserts a single element into the array at a position determined by a key.
 
TInt InsertIsqAllowDuplicatesL (const T &aRef, TKeyArrayFix &aKey)
 Inserts a single element into the array at a position determined by a key, allowing duplicates.
 
void ResizeL (TInt aCount)
 Changes the size of the array so that it contains the specified number of elements.
 
void ResizeL (TInt aCount, const T &aRef)
 Changes the size of the array so that it contains the specified number of elements.
 
const TArray< T > Array () const
 Constructs and returns a TArray<T> object.
 
- Public Member Functions inherited from CArrayFixBase
IMPORT_C ~CArrayFixBase ()
 Destructor.
 
TInt Count () const
 Gets the number of elements held in the array.
 
TInt Length () const
 Gets the length of an element.
 
IMPORT_C void Compress ()
 Compresses the array.
 
IMPORT_C void Reset ()
 Deletes all elements from the array and frees the memory allocated to the array buffer.
 
IMPORT_C TInt Sort (TKeyArrayFix &aKey)
 Sorts the elements of the array into key sequence.
 
IMPORT_C TAny * At (TInt anIndex) const
 Index into the array.
 
IMPORT_C TAny * End (TInt anIndex) const
 Return a pointer past contiguous elements starting at anIndex.
 
IMPORT_C TAny * Back (TInt anIndex) const
 Return a pointer to contiguous elements before anIndex.
 
IMPORT_C void Delete (TInt anIndex)
 Deletes a single element from the array at a specified position.
 
IMPORT_C void Delete (TInt anIndex, TInt aCount)
 Deletes one or more contiguous elements from the array, starting at a specific position.
 
IMPORT_C TAny * ExpandL (TInt anIndex)
 Expand the array to make room for a new record at anIndex.
 
IMPORT_C TInt Find (const TAny *aPtr, TKeyArrayFix &aKey, TInt &anIndex) const
 Find in the array using a sequential search.
 
IMPORT_C TInt FindIsq (const TAny *aPtr, TKeyArrayFix &aKey, TInt &anIndex) const
 Find in the array using a binary search.
 
IMPORT_C void InsertL (TInt anIndex, const TAny *aPtr)
 Insert a record into the array.
 
IMPORT_C void InsertL (TInt anIndex, const TAny *aPtr, TInt aCount)
 Insert aCount records into the array.
 
IMPORT_C TInt InsertIsqL (const TAny *aPtr, TKeyArrayFix &aKey)
 Insert in sequence, no duplicates allowed.
 
IMPORT_C TInt InsertIsqAllowDuplicatesL (const TAny *aPtr, TKeyArrayFix &aKey)
 Insert in sequence, allow duplicates.
 
IMPORT_C void ResizeL (TInt aCount, const TAny *aPtr)
 Resize the array to contain aCount records, copying a record into any new slots.
 
- Public Member Functions inherited from CBase
 CBase ()
 Default constructor.
 
virtual IMPORT_C ~CBase ()
 Virtual destructor.
 
TAny * operator new (TUint aSize, TAny *aBase) __NO_THROW
 Initialises the object to binary zeroes.
 
TAny * operator new (TUint aSize) __NO_THROW
 Allocates the object from the heap and then initialises its contents to binary zeroes.
 
TAny * operator new (TUint aSize, TLeave)
 Allocates the object from the heap and then initialises its contents to binary zeroes.
 
TAny * operator new (TUint aSize, TUint aExtraSize) __NO_THROW
 Allocates the object from the heap and then initialises its contents to binary zeroes.
 
TAny * operator new (TUint aSize, TLeave, TUint aExtraSize)
 Allocates the object from the heap and then initialises its contents to binary zeroes.
 

Additional Inherited Members

- Static Public Member Functions inherited from CBase
static IMPORT_C void Delete (CBase *aPtr)
 Deletes the specified object.
 
- Protected Member Functions inherited from CArrayFixBase
IMPORT_C CArrayFixBase (TBufRep aRep, TInt aRecordLength, TInt aGranularity)
 Constructor.
 
IMPORT_C void InsertRepL (TInt anIndex, const TAny *aPtr, TInt aReplicas)
 Insert aReplicas copies of a record into the array.
 
IMPORT_C void SetKey (TKeyArrayFix &aKey) const
 Set the key data.
 
IMPORT_C void SetReserveFlatL (TInt aCount)
 Reserve space to contain aCount items.
 
- Protected Member Functions inherited from CBase
virtual IMPORT_C TInt Extension_ (TUint aExtensionId, TAny *&a0, TAny *a1)
 Extension function.
 
- Static Protected Member Functions inherited from CArrayFixBase
static IMPORT_C TInt CountR (const CBase *aPtr)
 Return the number of items in the array.
 
static IMPORT_C const TAny * AtR (const CBase *aPtr, TInt anIndex)
 Return the address of an item in the array.
 

Detailed Description

template<class T>
class CArrayFix< T >

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.

API status
Published to all clients. Released API.

Definition at line 389 of file e32base.h.

Constructor & Destructor Documentation

◆ CArrayFix()

template<class T >
CArrayFix< T >::CArrayFix ( TBufRep  aRep,
TInt  aGranularity 
)
inline

Member Function Documentation

◆ AppendL() [1/3]

template<class T >
void CArrayFix< T >::AppendL ( const T &  aRef)
inline

Appends a single element onto the end of the array.

Parameters
aRefA reference to the class T element to be appended.

Leave condition: 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.

(generated from Symbian Developer Library)

◆ AppendL() [2/3]

template<class T >
void CArrayFix< T >::AppendL ( const T &  aRef,
TInt  aReplicas 
)
inline

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

Parameters
aRefA reference to the <class T> object to be replicated and appended.
aReplicasThe number of copies of the aRef element to be appended.

Leave condition: 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 condition: E32USER-CBase 28 if aReplicas is negative.

(generated from Symbian Developer Library)

◆ AppendL() [3/3]

template<class T >
void CArrayFix< T >::AppendL ( const T *  aPtr,
TInt  aCount 
)
inline

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

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

Leave condition: 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 condition: E32USER-CBase 23, if aCount is negative.

(generated from Symbian Developer Library)

◆ Array()

template<class T >
const TArray< T > CArrayFix< T >::Array ( ) const
inline

Constructs and returns a TArray<T> object.

(generated from Symbian Developer Library)

◆ At() [1/2]

template<class T >
T & CArrayFix< T >::At ( TInt  anIndex)
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.

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.

Panic condition: E32USER-CBase 21, if anIndex is negative or greater than or equal to the number of objects currently within the array.

(generated from Symbian Developer Library)

◆ At() [2/2]

template<class T >
const T & CArrayFix< T >::At ( TInt  anIndex) 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.

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.

Panic condition: E32USER-CBase 21, if anIndex is negative or greater than or equal to the number of objects currently within the array.

(generated from Symbian Developer Library)

◆ Back() [1/2]

template<class T >
T * CArrayFix< T >::Back ( TInt  anIndex)
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.

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.

Panic condition: E32USER-CBase 21, if anIndex is negative or greater than or equal to the number of objects currently within the array.

(generated from Symbian Developer Library)

◆ Back() [2/2]

template<class T >
const T * CArrayFix< T >::Back ( TInt  anIndex) 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.

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.

Panic condition: E32USER-CBase 21, if anIndex is negative or greater than or equal to the number of objects currently within the array.

(generated from Symbian Developer Library)

◆ End() [1/2]

template<class T >
T * CArrayFix< T >::End ( TInt  anIndex)
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.

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.

Panic condition: E32USER-CBase 21, if anIndex is negative or greater than or equal to the number of objects currently within the array.

(generated from Symbian Developer Library)

◆ End() [2/2]

template<class T >
const T * CArrayFix< T >::End ( TInt  anIndex) 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.

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.

Panic condition: E32USER-CBase 21, if anIndex is negative or greater than or equal to the number of objects currently within the array.

(generated from Symbian Developer Library)

◆ ExpandL()

template<class T >
T & CArrayFix< T >::ExpandL ( TInt  anIndex)
inline

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.

Parameters
anIndexThe position within the array where the array is to be expanded and the new class T object is to be constructed.

Leave condition: 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 condition: E32USER-CBase 21 if anIndex is negative or greater than the number of elements currently in the array.

(generated from Symbian Developer Library)

◆ ExtendL()

template<class T >
T & CArrayFix< 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 condition: 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.

(generated from Symbian Developer Library)

◆ Find()

template<class T >
TInt CArrayFix< T >::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.

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

(generated from Symbian Developer Library)

◆ FindIsq()

template<class T >
TInt CArrayFix< T >::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.

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

(generated from Symbian Developer Library)

◆ InsertIsqAllowDuplicatesL()

template<class T >
TInt CArrayFix< T >::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.

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

Leave condition: 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.

(generated from Symbian Developer Library)

◆ InsertIsqL()

template<class T >
TInt CArrayFix< T >::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.

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

Leave condition: 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 condition: 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.

(generated from Symbian Developer Library)

◆ InsertL() [1/3]

template<class T >
void CArrayFix< T >::InsertL ( TInt  anIndex,
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.

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 at position anIndex.

Leave condition: 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 condition: E32USER-CBase 21 if anIndex is negative, or is greater than the number of elements currently in the array.

(generated from Symbian Developer Library)

◆ InsertL() [2/3]

template<class T >
void CArrayFix< T >::InsertL ( TInt  anIndex,
const T &  aRef,
TInt  aReplicas 
)
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.

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

Leave condition: 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 condition: E32USER-CBase 21, if anIndex is negative or is greater than the number of elements currently in the array.

Panic condition: E32USER-CBase 28, if aReplicas is negative.

(generated from Symbian Developer Library)

◆ InsertL() [3/3]

template<class T >
void CArrayFix< T >::InsertL ( TInt  anIndex,
const T *  aPtr,
TInt  aCount 
)
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.

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

Leave condition: 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 condition: E32USER-CBase 21 if anIndex is negative or is greater than the number of elements currently in the array.

Panic condition: E32USER-CBase 23 if aCount is negative.

(generated from Symbian Developer Library)

◆ operator[]() [1/2]

template<class T >
T & CArrayFix< T >::operator[] ( TInt  anIndex)
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.

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.

Panic condition: E32USER-CBase 21, if anIndex is negative or greater than or equal to the number of objects currently within the array.

(generated from Symbian Developer Library)

◆ operator[]() [2/2]

template<class T >
const T & CArrayFix< T >::operator[] ( TInt  anIndex) 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.

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.

Panic condition: E32USER-CBase 21, if anIndex is negative or greater than or equal to the number of objects currently within the array.

(generated from Symbian Developer Library)

◆ ResizeL() [1/2]

template<class T >
void CArrayFix< T >::ResizeL ( TInt  aCount)
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.

Parameters
aCountThe number of elements the array is to contain after the resizing operation.

Panic condition: E32USER-CBase 24, if aCount is negative.

(generated from Symbian Developer Library)

◆ ResizeL() [2/2]

template<class T >
void CArrayFix< T >::ResizeL ( TInt  aCount,
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.

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

Panic condition: E32USER-CBase 24, if aCount is negative.

(generated from Symbian Developer Library)


The documentation for this class was generated from the following files: