Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

#include <e32cmn.h>

Class RArray< TInt >

class RArray< TInt > : private RPointerArrayBase;

Description

A simple and efficient specialized array of signed integers offering standard array behaviour.

Note that derivation from RPointerArrayBase is private.

Derivation

Members

Defined in RArray< TInt >:


Member functions


RArray()

inline RArray();

Description

Constructs an array object for an array of signed integers with default granularity.

The default granularity is 8.

Return value


RArray(TInt)

inline RArray(TInt aGranularity);

Description

Constructs an array object for an array of signed integers with the specified granularity.

Parameters

TInt aGranularity

The granularity of the array.

Return value

Panic codes

USER

127, if aGranularity is not positive or is greater than or equal to 0x10000000.


RArray(TInt,TInt)

inline RArray(TInt aMinGrowBy, TInt aFactor);

Description

C++ constructor with minimum growth step and exponential growth factor.

This constructs an array object for an array of signed integers with the specified minimum growth step and exponential growth factor.

Parameters

TInt aMinGrowBy

The minimum growth step of the array. Must be between 1 and 65535 inclusive.

TInt aFactor

The factor by which the array grows, multiplied by 256. For example 512 specifies a factor of 2. Must be between 257 and 32767 inclusive.

Return value

Panic codes

USER

192, if aMinGrowBy<=0 or aMinGrowBy>65535.

USER

193, if aFactor<=257 or aFactor>32767.


Close()

inline void Close();

Description

Closes the array and frees all memory allocated to the array.

The function must be called before this array object goes out of scope.


Count()const

inline TInt Count() const;

Description

Gets the number of signed integers in the array.

Return value

TInt

The number of signed integers in the array.


operator[](TInt)const

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

Description

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

The compiler chooses this function if the returned reference is used in an expression where the reference cannot be modified.

Parameters

TInt anIndex

The position of the signed integer within the array. The position is relative to zero, i.e. zero implies the entry at the beginning of the array.

Return value

const TInt &

A const reference to the signed integer at position anIndex within the array.

Panic codes

USER

130, if anIndex is negative, or is greater than the number of entries currently in the array.


operator[](TInt)

inline TInt& operator[](TInt anIndex);

Description

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

The compiler chooses this function if the returned reference is used in an expression where the reference can be modified.

Parameters

TInt anIndex

The position of the signed integer within the array. The position is relative to zero, i.e. zero implies the entry at the beginning of the array.

Return value

TInt &

A non-const reference to the signed integer at position anIndex within the array.

Panic codes

USER

130, if anIndex is negative, or is greater than the number of entries currently in the array.


Append(TInt)

inline TInt Append(TInt anEntry);

Description

Appends a signed integer onto the array.

Parameters

TInt anEntry

The signed integer to be appended.

Return value

TInt

KErrNone, if the insertion is successful, otherwise one of the system wide error codes.


Insert(TInt,TInt)

inline TInt Insert(TInt anEntry, TInt aPos);

Description

Inserts a signed integer into the array at the specified position.

Parameters

TInt anEntry

The signed integer to be inserted.

TInt aPos

The position within the array where the signed integer is to be inserted. The position is relative to zero, i.e. zero implies that an entry is inserted at the beginning of the array.

Return value

TInt

KErrNone, if the insertion is successful, otherwise one of the system wide error codes.

Panic codes

USER

131, if aPos is negative, or is greater than the number of entries currently in the array.


Remove(TInt)

inline void Remove(TInt anIndex);

Description

Removes the signed integer at the specified position from the array.

Parameters

TInt anIndex

The position within the array from where the signed integer is to be removed. The position is relative to zero, i.e. zero implies that an entry at the beginning of the array is to be removed.

Panic codes

USER

130, if anIndex is negative or is greater than the number of entries currently in the array.


Compress()

inline void Compress();

Description

Compresses the array down to a minimum.

After a call to this function, the memory allocated to the array is just sufficient for its entries. Subsequently adding a new signed integer to the array always results in a re-allocation of memory.


Reset()

inline void Reset();

Description

Empties the array.

The function frees all memory allocated to the array and resets the internal state so that it is ready to be reused.

This array object can be allowed to go out of scope after a call to this function.


Find(TInt)const

inline TInt Find(TInt anEntry) const;

Description

Finds the first signed integer in the array which matches the specified signed integer using a sequential search.

The find operation always starts at the low index end of the array. There is no assumption about the order of entries in the array.

Parameters

TInt anEntry

The signed integer to be found.

Return value

TInt

The index of the first matching signed integer within the array. KErrNotFound, if no matching entry can be found.


FindReverse(TInt)const

inline TInt FindReverse(TInt anEntry) const;

Description

Finds the last signed integer in the array which matches the specified signed integer using a sequential search.

The find operation always starts at the high index end of the array. There is no assumption about the order of entries in the array.

Parameters

TInt anEntry

The signed integer to be found.

Return value

TInt

The index of the last matching signed integer within the array. KErrNotFound, if no matching entry can be found.


FindInOrder(TInt)const

inline TInt FindInOrder(TInt anEntry) const;

Description

Finds the signed integer in the array that matches the specified signed integer using a binary search technique.

The function assumes that the array is in signed integer order.

Parameters

TInt anEntry

The signed integer to find.

Return value

TInt

The index of the matching signed integer within the array or KErrNotFound, if no match can be found.


FindInOrder(TInt,TInt &)const

inline TInt FindInOrder(TInt anEntry, TInt &anIndex) const;

Description

Finds the signed integer in the array that matches the specified signed integer using a binary search technique.

The function assumes that the array is in signed integer order.

Parameters

TInt anEntry

The signed integer to find.

TInt &anIndex

A TInt suplied by the caller. On return contains an index value. If the function returns KErrNone, this is the index of the matching signed integer within the array. If the function returns KErrNotFound, this is the index of the first signed integer within the array that is bigger than the signed integer being searched for - if no signed integers within the array are bigger, then the index value is the same as the total number of signed integers within the array.

Return value

TInt

KErrNone if a matching signed integer is found. KErrNotFound if no match can be found.


SpecificFindInOrder(TInt,TInt)const

inline TInt SpecificFindInOrder(TInt anEntry, TInt aMode) const;

Description

Finds the signed integer in the array that matches the specified signed integer using a binary search technique.

Where there is more than one matching element, it finds the first, last or any matching element as specified by the value of aMode.

The function assumes that the array is in signed integer order.

Parameters

TInt anEntry

The signed integer to be found.

TInt aMode

Specifies whether to find the first match, the last match or any match, as defined by one of the TArrayFindMode enum values.

Return value

TInt

KErrNotFound, if there is no matching element, otherwise the array index of a matching element - what the index refers to depends on the value of aMode: if this is EArrayFindMode_First, then the index refers to the first matching element; if this is EArrayFindMode_Any, then the index can refer to any of the matching elements; if this is EArrayFindMode_Last, then the index refers to first element that follows the last matching element - if the last matching element is also the last element of the array, then the index value is the same as the total number of elements in the array.


SpecificFindInOrder(TInt,TInt &,TInt)const

inline TInt SpecificFindInOrder(TInt anEntry, TInt &anIndex, TInt aMode) const;

Description

Finds the signed integer in the array that matches the specified signed integer using a binary search technique.

Where there is more than one matching element, it finds the first, last or any matching element as specified by the value of aMode.

The function assumes that the array is in signed integer order.

Parameters

TInt anEntry

The signed integer to be found.

TInt &anIndex

A TInt type supplied by the caller. On return, it contains an index value depending on whether a match is found and on the value of aMode. If there is no matching element in the array, then this is the index of the first element in the array that is bigger than the element being searched for - if no elements in the array are bigger, then the index value is the same as the total number of elements in the array. If there is a matching element, then what the index refers to depends on the value of aMode: if this is EArrayFindMode_First, then the index refers to the first matching element; if this is EArrayFindMode_Any, then the index can refer to any of the matching elements; if this is EArrayFindMode_Last, then the index refers to first element that follows the last matching element - if the last matching element is also the last element of the array, then the index value is the same as the total number of elements in the array.

TInt aMode

Specifies whether to find the first match, the last match or any match, as defined by one of the TArrayFindMode enum values.

Return value

TInt

KErrNone, if a matching element is found; KErrNotFound, if no suitable element can be found.


InsertInOrder(TInt)

inline TInt InsertInOrder(TInt anEntry);

Description

Inserts a signed integer into the array in signed integer order.

No duplicate entries are permitted. The array remains unchanged following an attempt to insert a duplicate entry.

The function assumes that existing entries within the array are in signed integer order.

Parameters

TInt anEntry

The signed integer to be inserted

Return value

TInt

KErrNone, if the insertion is successful; KErrAlreadyExists, if an attempt is being made to insert a duplicate entry; otherwise one of the other system wide error codes.


InsertInOrderAllowRepeats(TInt)

inline TInt InsertInOrderAllowRepeats(TInt anEntry);

Description

Inserts a signed integer into the array in signed integer order, allowing duplicates.

If anEntry is a duplicate of an existing entry in the array, then the new signed integer is inserted after the existing one. If more than one duplicate entry already exists in the array, then any new duplicate signed integer is inserted after the last one.

The function assumes that existing entries within the array are in signed integer order.

Parameters

TInt anEntry

The signed integer to be inserted.

Return value

TInt

KErrNone, if the insertion is successful, otherwise one of the system wide error codes.


AppendL(TInt)

inline void AppendL(TInt anEntry);

Description

Appends a signed integer onto the array.

The function leaves with one of the system wide error codes, if the operation fails.

NOTE: This function is NOT AVAILABLE to code running on the kernel side.

Parameters

TInt anEntry

The signed integer to be appended.


InsertL(TInt,TInt)

inline void InsertL(TInt anEntry, TInt aPos);

Description

Inserts a signed integer into the array at the specified position.

The function leaves with one of the system wide error codes, if the operation fails.

NOTE: This function is NOT AVAILABLE to code running on the kernel side.

Parameters

TInt anEntry

The signed integer to be inserted.

TInt aPos

The position within the array where the signed integer is to be inserted. The position is relative to zero, i.e. zero implies that an entry is inserted at the beginning of the array.

Panic codes

USER

131, if aPos is negative, or is greater than the number of entries currently in the array.


FindL(TInt)const

inline TInt FindL(TInt anEntry) const;

Description

Finds the first signed integer in the array which matches the specified signed integer using a sequential search.

The find operation always starts at the low index end of the array. There is no assumption about the order of entries in the array.

NOTE: This function is NOT AVAILABLE to code running on the kernel side.

Parameters

TInt anEntry

The signed integer to be found.

Return value

TInt

The index of the first matching signed integer within the array.

Leave codes

KErrNotFound,

if no matching entry can be found.


FindReverseL(TInt)const

inline TInt FindReverseL(TInt anEntry) const;

Description

Finds the last signed integer in the array which matches the specified signed integer using a sequential search.

The find operation always starts at the high index end of the array. There is no assumption about the order of entries in the array.

NOTE: This function is NOT AVAILABLE to code running on the kernel side.

Parameters

TInt anEntry

The signed integer to be found.

Return value

TInt

The index of the last matching signed integer within the array.

Leave codes

KErrNotFound,

if no matching entry can be found.


FindInOrderL(TInt)const

inline TInt FindInOrderL(TInt anEntry) const;

Description

Finds the signed integer in the array that matches the specified signed integer using a binary search technique.

The function assumes that the array is in signed integer order.

NOTE: This function is NOT AVAILABLE to code running on the kernel side.

Parameters

TInt anEntry

The signed integer to be found.

Return value

TInt

The index of the matching signed integer within the array.

Leave codes

KErrNotFound,

if no match can be found.


FindInOrderL(TInt,TInt &)const

inline void FindInOrderL(TInt anEntry, TInt &anIndex) const;

Description

Finds the signed integer in the array that matches the specified signed integer using a binary search technique.

The function assumes that the array is in signed integer order.

NOTE: This function is NOT AVAILABLE to code running on the kernel side.

Parameters

TInt anEntry

The signed integer to be found.

TInt &anIndex

A reference to a signed integer into which the function puts an index value: If the function returns , this is the index of the matching signed integer within the array. If the function leaves with KErrNotFound, this is the index of the first signed integer within the array that is bigger than the signed integer being searched for - if no signed integers within the array are bigger, then the index value is the same as the total number of signed integers within the array.

Leave codes

KErrNotFound

if no match can be found.


SpecificFindInOrderL(TInt,TInt)const

inline TInt SpecificFindInOrderL(TInt anEntry, TInt aMode) const;

Description

Finds the signed integer in the array that matches the specified signed integer using a binary search technique.

Where there is more than one matching element, it finds the first, last or any matching element as specified by the value of aMode.

The function assumes that the array is in signed integer order.

NOTE: This function is NOT AVAILABLE to code running on the kernel side.

Parameters

TInt anEntry

The signed integer to be found.

TInt aMode

Specifies whether to find the first match, the last match or any match, as defined by one of the TArrayFindMode enum values.

Return value

TInt

The array index of a matching element - what the index refers to depends on the value of aMode: if this is EArrayFindMode_First, then the index refers to the first matching element; if this is EArrayFindMode_Any, then the index can refer to any of the matching elements; if this is EArrayFindMode_Last, then the index refers to first element that follows the last matching element - if the last matching element is also the last element of the array, then the index value is the same as the total number of elements in the array.

Leave codes

KErrNotFound

if no matching entry exists.


SpecificFindInOrderL(TInt,TInt &,TInt)const

inline void SpecificFindInOrderL(TInt anEntry, TInt &anIndex, TInt aMode) const;

Description

Finds the signed integer in the array that matches the specified signed integer using a binary search technique.

Where there is more than one matching element, it finds the first, last or any matching element as specified by the value of aMode.

The function assumes that the array is in signed integer order.

NOTE: This function is NOT AVAILABLE to code running on the kernel side.

Parameters

TInt anEntry

The signed integer to be found.

TInt &anIndex

A TInt type supplied by the caller. On return, it contains an index value depending on whether a match is found and on the value of aMode. If there is no matching element in the array, then this is the index of the first element in the array that is bigger than the element being searched for - if no elements in the array are bigger, then the index value is the same as the total number of elements in the array. If there is a matching element, then what the index refers to depends on the value of aMode: if this is EArrayFindMode_First, then the index refers to the first matching element; if this is EArrayFindMode_Any, then the index can refer to any of the matching elements; if this is EArrayFindMode_Last, then the index refers to first element that follows the last matching element - if the last matching element is also the last element of the array, then the index value is the same as the total number of elements in the array.

TInt aMode

Specifies whether to find the first match, the last match or any match, as defined by one of the TArrayFindMode enum values.

Leave codes

KErrNotFound

if no matching entry exists.


InsertInOrderL(TInt)

inline void InsertInOrderL(TInt anEntry);

Description

Inserts a signed integer into the array in signed integer order.

No duplicate entries are permitted.

The function assumes that existing entries within the array are in signed integer order.

The function leaves with one of the system wide error codes, if the operation fails.

Note that the array remains unchanged following an attempt to insert a duplicate entry.

NOTE: This function is NOT AVAILABLE to code running on the kernel side.

Parameters

TInt anEntry

The signed integer to be inserted.


InsertInOrderAllowRepeatsL(TInt)

inline void InsertInOrderAllowRepeatsL(TInt anEntry);

Description

Inserts a signed integer into the array in signed integer order, allowing duplicates.

If anEntry is a duplicate of an existing entry in the array, then the new signed integer is inserted after the existing one. If more than one duplicate entry already exists in the array, then any new duplicate signed integer is inserted after the last one.

The function assumes that existing entries within the array are in signed integer order.

The function leaves with one of the system wide error codes, if the operation fails.

NOTE: This function is NOT AVAILABLE to code running on the kernel side.

Parameters

TInt anEntry

The signed integer to be inserted.


RArray(TInt *,TInt)

inline RArray(TInt *aEntries, TInt aCount);

Description

C++ constructor with a pointer to the first array entry in a pre-existing array, and the number of entries in that array.

This constructor takes a pointer to a pre-existing set of entries of type TInt objects. Ownership of the set of entries does not transfer to this RArray object.

The purpose of constructing an array in this way is to allow sorting and finding operations to be done without further allocation of memory.

Parameters

TInt *aEntries

A pointer to the first entry of type class TInt in the set of entries belonging to the existing array.

TInt aCount

The number of entries in the existing array.

Return value


GranularCompress()

inline void GranularCompress();

Description

Compresses the array down to a granular boundary.

After a call to this function, the memory allocated to the array is sufficient for its contained entries. Adding new signed integers to the array does not result in a re-allocation of memory until the total number of entries reaches a multiple of the granularity.


Reserve(TInt)

inline TInt Reserve(TInt aCount);

Description

Reserves space for the specified number of elements.

After a call to this function, the memory allocated to the array is sufficient to hold the number of integers specified. Adding new integers to the array does not result in a re-allocation of memory until the the total number of integers exceeds the specified count.

Parameters

TInt aCount

The number of integers for which space should be reserved

Return value

TInt

KErrNone If the operation completed successfully KErrNoMemory If the requested amount of memory could not be allocated


ReserveL(TInt)

inline void ReserveL(TInt aCount);

Description

Reserves space for the specified number of elements.

After a call to this function, the memory allocated to the array is sufficient to hold the number of integers specified. Adding new integers to the array does not result in a re-allocation of memory until the the total number of integers exceeds the specified count.

Parameters

TInt aCount

The number of integers for which space should be reserved

Leave codes

KErrNoMemory

If the requested amount of memory could not be allocated


Sort()

inline void Sort();

Description

Sorts the array entries into signed integer order.


Array()const

inline TArray< TInt > Array() const;

Description

Constructs and returns a generic array.

Return value

TArray< TInt >

A generic array representing this array.