»
Symbian OS v6.1 Edition for C++ »
API Reference »
Dynamic Arrays »
RArray<TInt>
Location:
e32std.h
Link against: euser.lib
RArray<TInt>
Support
Supported from 5.0
Description
A simple and efficient specialized array of signed integers
offering standard array behaviour.
Note that derivation from
RPointerArrayBase is
private.
Derivation
RArray<TInt> | A simple and efficient specialized array of signed integers offering standard array behaviour |
RPointerArrayBase | Base 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();
Description
Constructs an array object for an array of signed integers
with default granularity. The default granularity is 8.
RArray(TInt aGranularity);
Description
Constructs an array object for an array of signed integers
with a 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. |
|
Must be called before the array object goes out of
scope
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.
Emptying the array ready for reuse
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.
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 signed integer to the
array always results in a re-allocation of memory.
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.
TInt Count() const;
Description
Returns the number of signed integers in the array.
Return value
TInt |
The number of signed integers in the array. |
|
Inserting signed integers into the array
TInt Insert(TInt anEntry, TInt aPos);
Description
Inserts a signed integer into the array at a 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. 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. |
|
TInt InsertInOrder(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.
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. |
|
InsertInOrderAllowRepeats()
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. |
|
Appending signed integers onto the array
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. |
|
Removing signed integers from the array
void Remove(TInt anIndex);
Description
Removes the signed integer at a 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. 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. |
|
Finding signed integers in the array
TInt Find(TInt anEntry) const;
Description
Finds the first signed integer in the array which matches a
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.KErrNone, if no matching entry can be found. |
|
TInt FindInOrder(TInt anEntry) const;
TInt FindInOrder(TInt anEntry, TInt& anIndex) const;
Description
Use either of these functions to find the signed integer in
the array which matches a specified signed integer using a binary search
technique.
The functions assume that existing entries within the array
are in signed integer order.
Parameters
TInt anEntry |
The signed integer to be found. |
TInt& anIndex |
If supplied, a reference to a TInt into which
the function puts an index value: If the function returns
KErrNone, this is the index of the matching signed integer within
the array. If the function returnsKErrNotFound, this is the index
of the last signed integer within the array which logically precedes
anEntry.
|
|
Return value
TInt |
For the one argument function this is either: the index of
the matching signed integer within the array
or KErrNotFound, if no suitable entry can be found.For the two argument function this is either: KErrNone,
if a matching signed integer is found. KErrNotFound, if no
suitable entry can be found. |
|
void Sort ();
Description
Sorts the array entries into signed integer order.
const TInt& operator[](TInt anIndex) const;
TInt& operator[](TInt anIndex);
Description
Returns a reference to the signed integer located at a
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 signed 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 signed integer at
positionanIndexwithin the array |
TInt& |
A non-const reference to the signed integer at
positionanIndex within the array. |
|
TArray<TInt> Array() const;
Support
Supported from 6.0
Description
Constructs and returns a generic array.
Return value
TArray<TInt> |
A generic array representing this array. |
|
See also: