AIToolbox
A library that offers tools for AI problem solving.
AIToolbox::StorageVector Class Reference

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< Vectorvector
 This member provides a view of the pushed data. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ StorageVector() [1/2]

AIToolbox::StorageVector::StorageVector ( size_t  startSize)

Basic constructor.

Parameters
startSizeThe initial pre-reserved space for storage.

◆ StorageVector() [2/2]

AIToolbox::StorageVector::StorageVector ( Vector  vector)

Basic constructor.

Parameters
vectorThe vector with which to initialize storage (and the public view).

Member Function Documentation

◆ pop_back()

void AIToolbox::StorageVector::pop_back ( size_t  num = 1)

This function removes elements from the view vector.

Parameters
numThe number of elements to remove.

◆ push_back()

void AIToolbox::StorageVector::push_back ( double  val)

This function inserts a value in storage, and expands the view accordingly.

Parameters
valThe value to push.

◆ reserve()

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.

Parameters
sizeThe requested new size.

◆ resize()

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.

Parameters
sizeThe requested new size.

Member Data Documentation

◆ vector

Eigen::Ref<Vector> AIToolbox::StorageVector::vector

This member provides a view of the pushed data.


The documentation for this class was generated from the following file: