Location:
e32std.h
Link against: euser.lib
RArray<class T>
Supported from 5.0
A simple and efficient array of fixed length objects. The elements
of the array are instances of the template class T
.
The array offers standard array behaviour which includes insertion, appending and sorting of elements.
Note:
Where possible, this class should be used in preference to
CArrayFixFlat<class T>
.
Note also that derivation from
RArrayBase
is
private
.
|
Defined in RArray
:
Append()
, Array()
, Close()
, Compress()
, Count()
, Find()
, FindInOrder()
, FindInSignedKeyOrder()
, FindInUnsignedKeyOrder()
, GranularCompress()
, Insert()
, InsertInOrder()
, InsertInOrderAllowRepeats()
, InsertInSignedKeyOrder()
, InsertInSignedKeyOrderAllowRepeats()
, InsertInUnsignedKeyOrder()
, InsertInUnsignedKeyOrderAllowRepeats()
, RArray()
, Remove()
, Reset()
, Sort()
, SortSigned()
, SortUnsigned()
, operator[]()
RArray();
Default C++ constructor.
This constructs an array object for
an array of type class T
objects with default granularity and key
offset value. The default granularity is 8 and the defaul key offset value is
zero.
The size of class T
must be positive and must be
less than 640 otherwise the constructor raises a USER-129 panic.
RArray(TInt aGranularity);
C++ constructor with granularity.
This constructs an array object for an array of type class
T
objects with a specified granularity and default key offset
value. The default key offset value is zero.
The size of class T
must be positive and must be
less than 640, otherwise the constructor raises a USER-129 panic.
|
RArray(TInt aGranularity, TInt aKeyOffset);
C++ constructor with granularity and key offset.
This constructs an array object for an array of type class
T
objects with a specified granularity and a specified key offset
value.
The size of class T
must be positive and must be
less than 640, otherwise the constructor raises a USER-129 panic.
|
void Close();
Closes the array and frees all memory allocated to the array.
The function must be called before this array object is destroyed.
void Reset();
Empties the array, so that it is ready to be reused.
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();
Compresses the array down to a minimum.
After a call to this function, the memory allocated to the array is just sufficient for its contained objects. Adding a new object to the array always results in a re-allocation of memory.
void GranularCompress();
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 objects. Adding new objects to the array does not result in a re-allocation of memory until the the total number of objects reaches a multiple of the granularity.
TInt Count() const;
Gets the number of objects in the array.
|
TInt Insert(const T& anEntry, TInt aPos);
Inserts an object into the array at a specified position.
|
|
TInt InsertInOrder(const T& anEntry, TLinearOrder<T> anOrder);
Inserts an object of into the array in object order.
The algorithm for determining the order of two class
T
type objects is provided by a function supplied by the
caller.
No duplicate entries are permitted.
The function assumes that existing objects within the array are in object order.
|
|
TInt InsertInOrderAllowRepeats(const T& anEntry, TLinearOrder<T> anOrder);
Inserts an object into the array in object order, allowing duplicates.
The algorithm for determining the order of two class
T
type objects is provided by a function supplied by the
caller.
If anEntry
is a duplicate of an existing object
in the array, then the new object is inserted after the existing object. If
more than one duplicate object already exists in the array, then
anEntry
is inserted after the last one.
The function assumes that existing objects within the array are in object order.
|
|
TInt InsertInSignedKeyOrder(const T& anEntry);
Inserts an object into the array in ascending signed key order.
The order of two class T
type objects is based
on comparing a TInt
value located at the key offset position
within the classT
object.
No duplicate entries are permitted.
|
|
TInt InsertInSignedKeyOrderAllowRepeats(const T& anEntry);
Inserts an object into the array in ascending signed key order, allowing duplicates.
The order of two class T
type objects is based
on comparing a TInt
value located at the key offset position
within the classT
object.
If anEntry
is a duplicate of an existing object
in the array, then the new object is inserted after the existing object. If
more than one duplicate object already exists in the array, then any new
duplicate object is inserted after the last one.
|
|
TInt InsertInUnsignedKeyOrder(const T& anEntry);
Inserts an object into the array in ascending unsigned key order, not alloing duplicate entries.
The order of two class T
type objects is based
on comparing a TUint
value located at the key offset position
within the classT
object.
|
|
TInt InsertInUnsignedKeyOrderAllowRepeats(const T& anEntry);
Inserts an object into the array in ascending unsigned key order, allowing duplicates.
The order of two class T
type objects is based
on comparing a TUint
value located at the key offset position
within the classT
object.
If anEntry
is a duplicate of an existing object
in the array, then the new object is inserted after the existing object. If
more than one duplicate object already exists in the array, then any new
duplicate object is inserted after the last one.
|
|
TInt Append(const T& anEntry);
Apends an object onto the array.
|
|
void Remove(TInt anIndex);
Removes the object at a specified position from the array.
|
TInt Find(const T& anEntry) const;
Finds the first object in the array which matches the specified object using a sequential search.
Matching is based on the comparison of a TInt
value at the key offset position within the objects.
The find operation always starts at the low index end of the array. There is no assumption about the order of objects in the array.
|
|
TInt Find(const T& anEntry, TIdentityRelation<T> anIdentity) const;
Finds the first object in the array which matches the specified object using a sequential search and a matching algorithm.
The algorithm for determining whether two class
T
type objects match is provided by a function supplied by the
caller.
The find operation always starts at the low index end of the array. There is no assumption about the order of objects in the array.
|
|
TInt FindInOrder(const T& anEntry, TLinearOrder<T> anOrder) const;
TInt FindInOrder(const T& anEntry, TInt& anIndex, TLinearOrder<T> anOrder) const;
Finds the object in the array which matches the specified object using a binary search technique and an ordering algorithm.
The functions assume that existing objects within the array
are in object order as determined by an algorithm supplied by the caller and
packaged as aTLinearOrder<T>
.
|
|
TInt FindInSignedKeyOrder(const T& anEntry) const;
TInt FindInSignedKeyOrder(const T& anEntry, TInt& anIndex) const;
Finds the object in the array which matches the specified object using a binary search technique.
The functions assume that existing objects within the array are in signed key order.
|
|
TInt FindInUnsignedKeyOrder(const T& anEntry) const;
TInt FindInUnsignedKeyOrder(const T& anEntry, TInt& anIndex) const;
Finds the object in the array which matches the specified object using a binary search technique.
The functions assume that existing objects within the
array are in unsigned key order.
|
|
void Sort(TLinearOrder<T> anOrder);
Sorts the objects within the array using the specified
TLinearOrder
.
The sort order is determined by an algorithm supplied by the
caller and packaged as aTLinerOrder<T>
.
|
void SortSigned();
Sorts the objects within the array — the sort order is assumed to be in signed integer order.
void SortUnsigned();
Sorts the objects within the array — the sort order is assumed to be in signed integer order.
const T& operator[](TInt anIndex) const;
T& operator[](TInt anIndex);
Gets a reference to an object 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.
|
|
TArray<T> Array() const;
Supported from 6.0
Constructs and returns a generic array.
|