#include <rdArray.h>
Public Member Functions | |
| virtual | ~rdArray () |
| Destructor. | |
| rdArray (const T &aDefaultValue, int aSize=0, int aCapacity=rdArray_CAPMIN) | |
| Default constructor. | |
| rdArray (const rdArray< T > &aArray) | |
| Coppy constructor. | |
| T & | operator[] (int aIndex) const |
| Get the array element at a specified index. | |
| rdArray< T > & | operator= (const rdArray< T > &aArray) |
| Assign this array to a specified array. | |
| bool | computeNewCapacity (int aMinCapacity, int &rNewCapacity) |
| Compute a new capacity that is at least as large as a specified minimum capacity; this method does not change the capacity, it simply computes a new recommended capacity. | |
| bool | ensureCapacity (int aCapacity) |
| Ensure that the capacity of this array is at least the specified amount. | |
| void | trim () |
| Trim the capacity of this array so that it is one larger than the size of this array. | |
| int | getCapacity () const |
| Get the capacity of this storage instance. | |
| void | setCapacityIncrement (int aIncrement) |
| Set the amount by which the capacity is increased when the capacity of of the array in exceeded. | |
| int | getCapacityIncrement () const |
| Get the amount by which the capacity is increased. | |
| bool | setSize (int aSize) |
| Set the size of the array. | |
| int | getSize () const |
| Get the size of the array. | |
| int | append (const T &aValue) |
| Append a value onto the array. | |
| int | append (const rdArray< T > &aArray) |
| Append an array of values. | |
| int | insert (int aIndex, const T &aValue) |
| Insert a value into the array at a specified index. | |
| int | remove (int aIndex) |
| Remove a value from the array at a specified index. | |
| void | set (int aIndex, const T &aValue) |
| Set the value at a specified index. | |
| T & | get (int aIndex) const |
| Get the value at a specified array index. | |
| T & | getLast () const |
| Get the last value in the array. | |
| int | searchBinary (const T &aValue, bool aFindFirst=false, int aLo=-1, int aHi=-1) const |
| Search for the largest value in the array that is less than or equal to a specified value. | |
Protected Attributes | |
| int | _size |
| Size of the array. | |
| int | _capacity |
| Current capacity of the array. | |
| int | _capacityIncrement |
| Increment by which the current capacity is increased when the capacity of this storage instance is reached. | |
| T | _defaultValue |
| Default value of elements. | |
| T * | _array |
| Array of values. | |
Private Member Functions | |
| void | setNull () |
| Set all member variables to their null or default values. | |
The capacity of the class grows as needed. To use this template for a class of type T, class T should implement the following methods: default constructor, copy constructor, assignment operator (=), equality operator (==), and less than operator (<).
|
|||||||||
|
Destructor. When the array is deleted, references to elements of this array become invalid. |
|
||||||||||||||||||||
|
Default constructor.
|
|
||||||||||
|
Coppy constructor.
|
|
||||||||||
|
Append a value onto the array.
|
|
||||||||||||||||
|
Compute a new capacity that is at least as large as a specified minimum capacity; this method does not change the capacity, it simply computes a new recommended capacity. If the capacity increment is negative, the current capacity is doubled until the computed capacity is greater than or equal to the specified minimum capacity. If the capacity increment is positive, the current capacity increment by this amount until the computed capacity is greater than or equal to the specified minimum capacity. If the capacity increment is zero, the computed capacity is set to the current capacity and false is returned.
|
|
||||||||||
|
Ensure that the capacity of this array is at least the specified amount. Note that the newly allocated array elements are not initialized.
|
|
||||||||||
|
Get the value at a specified array index. If the index is negative or passed the end of the array, an exception is thrown. For faster execution, the array elements can be accessed through the overloaded operator[], which does no bounds checking.
|
|
|||||||||
|
Get the last value in the array.
|
|
|||||||||
|
Get the size of the array.
|
|
||||||||||||||||
|
Insert a value into the array at a specified index. This method is relatively computationally costly since many of the array elements may need to be shifted.
|
|
||||||||||
|
Assign this array to a specified array. This operator makes a complete copy of the specified array; all member variables are copied. So, the result is two identical, independent arrays.
|
|
||||||||||
|
Get the array element at a specified index.
This overloaded operator can be used both to set and get element values: This operator is intended for accessing array elements with as little overhead as possible, so no error checking is performed. The caller must make sure the specified index is within the bounds of the array. If error checking is desired, use rdArray::get().
|
|
||||||||||
|
Remove a value from the array at a specified index. This method is relatively computationally costly since many of the array elements may need to be shifted.
|
|
||||||||||||||||||||||||
|
Search for the largest value in the array that is less than or equal to a specified value. If there is more than one element with this largest value, the index of the first of these elements can optionally be found, but this can be up to twice as costly. This method assumes that the array element values monotonically increase as the array index increases. Note that monotonically increase means never decrease, so it is permissible for elements to A binary search is performed (i.e., the array is repeatedly subdivided into two bins one of which must contain the specified until the approprite element is identified), so the performance of this method is approximately ln(n), where n is the size of the array.
|
|
||||||||||||||||
|
Set the value at a specified index.
|
|
||||||||||
|
Set the amount by which the capacity is increased when the capacity of of the array in exceeded. If the specified increment is negative or this method is called with no argument, the capacity is set to double whenever the capacity is exceeded.
|
|
||||||||||
|
Set the size of the array. This method can be used to either increase or decrease the size of the array. If this size of the array is increased, the new elements are initialized to the default value that was specified at the time of construction. Note that the size of an array is different than its capacity. The size indicates how many valid elements are stored in an array. The capacity indicates how much the size of the array can be increased without allocated more memory. At all times size <= capacity.
|
|
|||||||||
|
Trim the capacity of this array so that it is one larger than the size of this array. This is useful for reducing the amount of memory used by this array. This capacity is kept at one larger than the size so that, for example, an array of characters can be treated as a NULL terminated string. |
|
|||||
|
Increment by which the current capacity is increased when the capacity of this storage instance is reached. If negative, capacity doubles. |
|
|||||
|
Size of the array. Also the index of the first empty array element. |
1.3