#include <rtcollect.h>
Inheritance diagram for lrt::Array:

Public Methods | |
| Array (int length) | |
| Creates an array of given length. | |
| Array (const Array< T > &) | |
| Copies the contents of the given array into this one. | |
| Array (const T *ptr, int off, int len) | |
| Creates an array by extracting data from the given C pointer. More... | |
| virtual | ~Array () |
| Destroys the array and all contained data. | |
| int | length () const |
| Returns the array's length. More... | |
| const T & | operator[] (int index) const |
| Returns a reference to the index'th element of the array. More... | |
| T & | operator[] (int index) |
| Returns a reference to the index'th element of the array. More... | |
| Array< T > & | operator= (const Array< T > &) |
| Copies the contents of the given array over to this one. | |
| const T * | getData () const |
| Returns a C-style pointer to the array's data. More... | |
| int | indexOf (const T &elem, int pos=0) const |
Finds the first occurence of elem, starting from pos. More... | |
| void | exchange (int p1, int p2) |
| Exchanges the elements at the given positions. | |
| void | sort () |
| Sorts the array using a quicksort algorithm and the default comparison function stdCompare. | |
| void | reverse () |
| Reverses the order of all the elements in the array. | |
| void | sort (int(*compareFun)(const T &, const T &), int l=0, int r=Math::MAX_INT) |
| Sorts the array using a quicksort algorithm and a custom comparison function. | |
Protected Methods | |
| int | check (int) |
| Checks if a given array index is valid. More... | |
| int | checkConst (int) const |
| Checks if a given array index is valid. More... | |
Static Protected Methods | |
| void | copy (const Array< T > *source, int srcPos, Array< T > *dest, int destPos, int length) |
| Copies some data between arrays very fastly. | |
Protected Attributes | |
| int | len |
| The array's length. | |
| T * | data |
| The array's data. | |
Methods for access to elements are provided.
|
||||||||||||||||||||
|
Creates an array by extracting data from the given C pointer.
You are responsible yourself for checking the validity of the pointer, |
|
||||||||||
|
Checks if a given array index is valid. If not, exits the application. This method should be used to check accesses which may modify the array. Reimplemented in lrt::Vector. |
|
||||||||||
|
Checks if a given array index is valid. If not, exits the application. This method should be used to check accesses which may not modify the array. |
|
|||||||||
|
Returns a C-style pointer to the array's data. The data cannot be modified through this pointer, but changes made to the array using the [] operators will be visible by it. This implies that should only use the pointer for a short time, e.g. to call some system C functions with it. |
|
||||||||||||||||
|
Finds the first occurence of
Note that an |
|
|||||||||
|
Returns the array's length. For Array<T> objects, the value will be constant during their lifetime. |
|
||||||||||
|
Returns a reference to the index'th element of the array.
This method is used for changing the element. If Reimplemented in lrt::Vector. |
|
||||||||||
|
Returns a reference to the index'th element of the array.
If Reimplemented in lrt::Vector. |