AIToolbox
A library that offers tools for AI problem solving.
|
This class provides an Eigen-compatible automatically resized Vector. More...
#include <AIToolbox/Utils/StorageEigen.hpp>
Public Member Functions | |
StorageVector (size_t startSize) | |
Basic constructor. More... | |
StorageVector (Vector vector) | |
Basic constructor. More... | |
void | pop_back (size_t num=1) |
This function removes elements from the view vector. More... | |
void | push_back (double val) |
This function inserts a value in storage, and expands the view accordingly. More... | |
void | resize (size_t size) |
This function resizes the view to the requested size. More... | |
void | reserve (size_t size) |
This function reserves space in the underlying storage. More... | |
Public Attributes | |
Eigen::Ref< Vector > | vector |
This member provides a view of the pushed data. More... | |
This class provides an Eigen-compatible automatically resized Vector.
The interface is deliberately simple for now. This class simply maintains a public reference to the internal storage container.
Pushing and popping modifies the view, while the storage gets increased automatically when needed.
AIToolbox::StorageVector::StorageVector | ( | size_t | startSize | ) |
Basic constructor.
startSize | The initial pre-reserved space for storage. |
AIToolbox::StorageVector::StorageVector | ( | Vector | vector | ) |
Basic constructor.
vector | The vector with which to initialize storage (and the public view). |
void AIToolbox::StorageVector::pop_back | ( | size_t | num = 1 | ) |
This function removes elements from the view vector.
num | The number of elements to remove. |
void AIToolbox::StorageVector::push_back | ( | double | val | ) |
This function inserts a value in storage, and expands the view accordingly.
val | The value to push. |
void AIToolbox::StorageVector::reserve | ( | size_t | size | ) |
This function reserves space in the underlying storage.
This function does not modify the view. We also call Eigen's conservativeResize
so that already stored data is maintained.
size | The requested new size. |
void AIToolbox::StorageVector::resize | ( | size_t | size | ) |
This function resizes the view to the requested size.
We first call reserve(size_t) to make sure that the storage is appropriately sized.
size | The requested new size. |
Eigen::Ref<Vector> AIToolbox::StorageVector::vector |
This member provides a view of the pushed data.