![]() |
GemaCoreLib
The GeMA Core library
|
A simple vector for Plain Old Data (POD) types with the control size variable type parameterized to allow for a smaller class size with ControlSize = unsigned int, with smaller vector size limits, or for a bigger class with ControlSize = size_t. Also receives as parameter the default gorwing strategy applied by its resize procedure. More...
#include <gmPODVector.h>
Public Types | |
typedef T | DataType |
The stored data type. | |
Public Member Functions | |
GmPODVector () | |
Default constructor. Creates an empty vector. | |
GmPODVector (ControlSize nvalues) | |
The constructor initializing the vector with the given size. The vector contents is NOT initialized. | |
~GmPODVector () | |
Destructor. | |
ControlSize | size () const |
Returns the vector size. | |
ControlSize | capacity () const |
Returns the vector allocated capacity. | |
const T * | data () const |
Returns a pointer to the data inside the vector. | |
T * | data () |
Non-const overload for data() | |
const T & | operator[] (ControlSize index) const |
Standard indexing operator. | |
T & | operator[] (ControlSize index) |
Non-const overload for the standard indexing operator. | |
bool | append (const T &v) |
Appends v to the vector end, growing the vector, if needed, using the growth algorithm specified as the Grow template parameter. Returns true on success, false on error. | |
void | remove (ControlSize index, ControlSize numValues) |
Removes numValues entries from the vector starting at index. | |
bool | resize (ControlSize newSize, GmPODGrowT grow=Grow) |
Resizes the vector to the given size using the speciefied grow policy. More... | |
void | shrink () |
Shriks the allocated size to match the vector size if possible. Never fails but might do nothing. | |
void | clear () |
Clears the vector deallocating used memory. | |
Private Member Functions | |
Q_DISABLE_COPY (GmPODVector) | |
Private Attributes | |
T * | _data |
The vector. | |
ControlSize | _size |
The vector size. | |
ControlSize | _alloc |
The allocated space. | |
A simple vector for Plain Old Data (POD) types with the control size variable type parameterized to allow for a smaller class size with ControlSize = unsigned int, with smaller vector size limits, or for a bigger class with ControlSize = size_t. Also receives as parameter the default gorwing strategy applied by its resize procedure.
|
inline |
Resizes the vector to the given size using the speciefied grow policy.
If newSize is bigger than the current allocated size, the vector will be grown using the policy. New entries are NOT initialized. If new size is smaller than the current size, space will be removed from the vector end. The allocated space never shrinks, and so reducing the size never fails. You can explicitely reduce the allocated size by calling shrink().