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

Public Methods | |
| Vector (int length=0) | |
| Creates a growable array of given initial length. | |
| Vector (const Vector< T > &) | |
| Creates a new growable array by copying the elements of the given array over. | |
| 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 this array through which the element can be changed. More... | |
| Vector< T > & | operator= (const Vector< T > &) |
| Copies the data from another array over to this one. | |
| int | check (int) |
| Checks an array index for validity. More... | |
| Vector< T > & | operator+= (const T &) |
| Appends an element to this array. More... | |
| Vector< T > & | operator+= (const Array< T > &) |
| Appends all the elements from another array to this one. More... | |
| void | insert (T elem, int before) |
| Inserts an element before the given index. More... | |
| void | remove (int pos) |
Removes the element at index pos. More... | |
| void | remove (int start, int length) |
Removes all elements between indexes start and (not including) start + length. | |
| void | clear () |
| Removes all elements. | |
Protected Methods | |
| int | up2pow (int val) |
Returns the smallest power of two (but at least 16) which is equal or larger than val. More... | |
Static Protected Methods | |
| void | copy (const Array< T > *source, int srcPos, Vector< T > *dest, int destPos, int length) |
| Copies some data over to a vector. More... | |
Protected Attributes | |
| int | capacity |
| The internal allocated memory size. | |
If there is enough memory available, setting an element with positive index will never fail using this class, but resize the array instead so that it becomes large enough to hold the given number of elements. Elements can also easily be appended to the array (this method should be reasonably fast). Some methods are provided to insert or remove elements from the middle of the array, but these are slow.
|
||||||||||
|
Checks an array index for validity. If the index is too large, the array is resized appropriately. Reimplemented from lrt::Array. |
|
||||||||||||||||||||||||||||
|
Copies some data over to a vector. If the vector is not large enough to hold the data, it is first resized. |
|
||||||||||||||||
|
Inserts an element before the given index.
Since this method moves around all elements after |
|
||||||||||
|
Appends all the elements from another array to this one. Most times, this method should be quite fast. |
|
||||||||||
|
Appends an element to this array. Most times, this method should be quite fast. |
|
||||||||||
|
Returns a reference to the index'th element of this array through which the element can be changed.
If the array is not yet large enough to store
Note: Be careful when exporting references to Reimplemented from lrt::Array. |
|
||||||||||
|
Returns a reference to the index'th element of the array.
If Reimplemented from lrt::Array. |
|
||||||||||
|
Removes the element at index
Since this method moves around all elements after |
|
||||||||||
|
Returns the smallest power of two (but at least 16) which is equal or larger than This method is used to grow the array exponentially. |