ContRap-Libraries
|
Class Vector is a template vector type. More...
#include <vector.h>
Public Member Functions | |
Vector (MetaInfo *meta_info) | |
Creates a new template object from type info. | |
~Vector () | |
Releases the memory. | |
void | resize (size_t size) |
Resizes the vector to the given size. | |
DPtr | get_element (size_t index) |
Returns the pointer to the array elements. | |
void | set_element (size_t index, const DPtr &value) |
Sets the value of the element at the given position. | |
Protected Attributes | |
MetaInfo * | meta_info |
Template parameter. | |
char * | data |
Data of the vector. | |
size_t | size |
Size of the vector. | |
size_t | max_size |
Maxium size. |
Class Vector is a template vector type.
The vector behaves on the one hand like an STL container. On the other hand it has a constant time representation as a C-array of container elements.
In contrast to an ordinary STL vector, the template parameter of this class is set at runtime.
crp::Vector::Vector | ( | MetaInfo * | meta_info | ) |
Creates a new template object from type info.
meta_info | Type information of the objects template parameter. |
crp::Vector::~Vector | ( | ) |
Releases the memory.
DPtr crp::Vector::get_element | ( | size_t | index | ) |
Returns the pointer to the array elements.
index | Index of the element |
void crp::Vector::resize | ( | size_t | size | ) |
Resizes the vector to the given size.
size | New vector size. |
void crp::Vector::set_element | ( | size_t | index, |
const DPtr & | value | ||
) |
Sets the value of the element at the given position.
Be sure that the new value can be casted to the type of the vector. An error is raised if not.
index | Index of the element |
value | New value of the element |
char* crp::Vector::data [protected] |
Data of the vector.
size_t crp::Vector::max_size [protected] |
Maxium size.
MetaInfo* crp::Vector::meta_info [protected] |
Template parameter.
size_t crp::Vector::size [protected] |
Size of the vector.