|
NXWidgets
1.19
|
#include <tnxarray.hxx>
Public Member Functions | |
| TNxArray () | |
| TNxArray (int initialSize) | |
| ~TNxArray () | |
| void | preallocate (void) |
| const int | size (void) const |
| void | push_back (const T &value) |
| void | insert (const int index, const T &value) |
| void | pop_back (void) |
| void | erase (const int index) |
| T & | at (const int index) const |
| bool | empty (void) const |
| void | clear () |
| T & | operator[] (const int index) const |
Private Member Functions | |
| void | reallocate (const int newSize) |
| void | resize (void) |
Private Attributes | |
| T * | m_data |
| int | m_size |
| int | m_reservedSize |
Class providing a dynamic array; that is, an array that will automatically grow to accommodate new data. It provides a fast way to randomly access a list of data. Essentially, it provides the most important functionality of the STL vector class without any of the overhead of including an STL class.
If the data to be stored will store a lot of data that will predominantly be read sequentially, consider using the LinkedList class instead. Resizing the list is an expensive operation that will occur frequently when filling the array with large amounts of data. Adding new data to the linked list is very inexpensive.
Definition at line 109 of file tnxarray.hxx.
Constructor. Creates an un-allocated array. The array will be allocated when items are added to it or when preallocate() is called.
Definition at line 232 of file tnxarray.hxx.
Constructor. Creates an allocated array.
| initialSize | The initial size of the array. |
Definition at line 243 of file tnxarray.hxx.
Destructor.
Definition at line 252 of file tnxarray.hxx.
|
inline |
Get a value at the specified location. Does not perform bounds checking.
| index | The index of the desired value. |
Definition at line 404 of file tnxarray.hxx.
| void TNxArray< T >::clear | ( | ) |
Remove all data.
Definition at line 428 of file tnxarray.hxx.
|
inline |
Check if the array has any data.
Definition at line 413 of file tnxarray.hxx.
| void TNxArray< T >::erase | ( | const int | index | ) |
Erase a single value at the specified index
Definition at line 326 of file tnxarray.hxx.
| void TNxArray< T >::insert | ( | const int | index, |
| const T & | value | ||
| ) |
Insert a value into the array.
| index | The index to insert into. |
| value | The value to insert. |
Definition at line 295 of file tnxarray.hxx.
| T & TNxArray< T >::operator[] | ( | const int | index | ) | const |
Overload the [] operator to allow array-style access.
| index | The index to retrieve. |
Definition at line 419 of file tnxarray.hxx.
| void TNxArray< T >::pop_back | ( | void | ) |
Remove the last element from the array.
Definition at line 283 of file tnxarray.hxx.
| void TNxArray< T >::preallocate | ( | void | ) |
Set the initial size of the array. Normally, the array is unallocated until the first data is pushed into the array. That works great for stacks and lists. But if you want a array of unitialized elements, then this method will preallocate the array for you.
| void TNxArray< T >::push_back | ( | const T & | value | ) |
Add a value to the end of the array.
| value | The value to add to the array. |
Definition at line 267 of file tnxarray.hxx.
|
private |
Re-allocate the array to this size;
Definition at line 348 of file tnxarray.hxx.
|
private |
Resize the array if it is full.
Definition at line 380 of file tnxarray.hxx.
|
inline |
Get the size of the array.
Definition at line 261 of file tnxarray.hxx.
|
private |
Internal array of data items
Definition at line 112 of file tnxarray.hxx.
|
private |
Total size of the array including unpopulated slots
Definition at line 114 of file tnxarray.hxx.
|
private |
Number of items in the array
Definition at line 113 of file tnxarray.hxx.
1.8.13