Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



Location: e32std.h
Link against: euser.lib

Class RArray<TUint>

RArray<TUint>

Support

Supported from 5.0

Description

Array of unsigned integers.

The array is a simple and efficient specialized array of unsigned integers offering standard array behaviour.

Note that derivation from RPointerArrayBase is private.

Derivation

RArray<TUint>Array of unsigned integers
RPointerArrayBaseBase class used in the derivation of RPointerArray, RArray<TInt> and RArray<TUint>

Defined in RArray:
Append(), Array(), Close(), Compress(), Count(), Find(), FindInOrder(), GranularCompress(), Insert(), InsertInOrder(), InsertInOrderAllowRepeats(), RArray(), Remove(), Reset(), Sort(), operator[]()


Construction


RArray()

RArray();

Description

Default C++ constructor. This constructs an array object for an array of unsigned integers with default granularity.

The default granularity of the array is 8.


RArray()

RArray(TInt aGranularity);

Description

C++ constructor with granularity.

This constructs an array object for an array of unsigned integers with the specified granularity.

Parameters

TInt aGranularity

The granularity of the array. This value must be positive and must be less than 0x10000000, otherwise the constructor raises a USER-127 panic.

[Top]


Must be called before the array object goes out of scope


Close()

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.

[Top]


Emptying the array ready for reuse


Reset()

void Reset();

Description

Empties the array. It 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.

[Top]


Compressing the array


Compress()

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. Adding a new unsigned integer to the array always results in a re-allocation of memory.


GranularCompress()

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

[Top]


Information


Count()

TInt Count() const;

Description

Gets the number of unsigned integers in the array.

Return value

TInt

The number of unsigned integers in the array.

[Top]


Inserting unsigned integers into the array


Insert()

TInt Insert(TInt anEntry, TInt aPos);

Description

Inserts an unsigned integer into the array at the specified position.

Parameters

TInt anEntry

The unsigned integer to be inserted.

TInt aPos

The position within the array where the unsigned 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. This value must not be negative and must not be greater than the number of entries currently in the array, otherwise the function raises a USER-131 panic.

Return value

TInt

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


InsertInOrder()

TInt InsertInOrder(TInt anEntry);

Description

Inserts an unsigned integer into the array in unsigned integer order.

No duplicate entries are permitted.

Note:

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

Parameters

TInt anEntry

The unsigned integer to be inserted.

Return value

TInt

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


InsertInOrderAllowRepeats()

TInt InsertInOrderAllowRepeats(TInt anEntry);

Description

Inserts an unsigned integer into the array in unsigned integer order, allowing duplicates.

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

Note:

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

Parameters

TInt anEntry

The unsigned integer to be inserted

Return value

TInt

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

[Top]


Appending unsigned integers onto the array


Append()

TInt Append(TInt anEntry);

Description

Appends an unsigned integer onto the array.

Parameters

TInt anEntry

The unsigned integer to be appended.

Return value

TInt

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

[Top]


Removing unsigned integers from the array


Remove()

void Remove(TInt anIndex);

Description

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

Parameters

TInt anIndex

The position within the array from where the unsigned 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. This value must not be negative and must not be greater than the number of entries currently in the array, otherwise the function raises a USER-130 panic.

[Top]


Finding unsigned integers in the array


Find()

TInt Find(TInt anEntry) const;

Description

Finds the first unsigned integer in the array which matches the specified value, 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 unsigned integer to be found.

Return value

TInt

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


FindInOrder()

TInt FindInOrder(TInt anEntry) const;

Description

Finds the unsigned integer in the array which matches the specified value, using a binary search technique.

The functions assume that existing entries within the array are in unsigned integer order.

Parameters

TInt anEntry

The unsigned integer to be found.

Return value

TInt

This is either: the index of the matching unsigned integer within the arrayor KErrNotFound, if no suitable entry can be found.


FindInOrder()

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

Description

Finds the unsigned integer in the array which matches the specified value, using a binary search technique. If the index cannot be found, the function returns the index of the last unsigned integer within the array which logically precedes anEntry.

The functions assume that existing entries within the array are in unsigned integer order.

Parameters

TInt anEntry

The unsigned integer to be found.

TInt& anIndex

On return, contains an index value. If the function returns KErrNone, this is the index of the matching unsigned integer within the array. If the function returns KErrNotFound, this is the index of the last unsigned integer within the array which logically precedes anEntry.

Return value

TInt

This is either: KErrNone, if a matching unsigned integer is found. KErrNotFound, if no suitable entry can be found.

[Top]


Sorting the array


Sort()

void Sort ();

Description

Sorts the array entries into unsigned integer order.

[Top]


Indexing into the array


operator[]()

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

Description

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

Two versions of the operator are supplied. The compiler chooses the appropriate version based on the use made of the returned reference. If the returned reference is used in an expression where the reference can be modified, then the non-const version is chosen.

Parameters

TInt anIndex

The position of the unsigned integer within the array. The position is relative to zero, i.e. zero implies the entry at the beginning of the array. This value must not be negative and must not be greater than the number of entries currently in the array, otherwise the operator raises a USER-130 panic.

Return value

TInt&

A const reference to the unsigned integer at positionanIndex within the array

[Top]


Creating a generic array


Array()

TArray<TUint> Array() const;

Support

Supported from 6.0

Description

Constructs and returns a generic array.

Return value

TArray<TUint>

A generic array representing this array.

See also: