iDynTree::VectorDynSize class

Class providing a simple form of vector with dynamic size.

It is designed to provide seamless integration with SWIG.

Derived classes

class JointDOFsDoubleArray
Class for storing a vector of scalar values, one for each internal coordinate in a model.
class JointPosDoubleArray
Class for storing a vector of scalar values, one for each internal position coordinate in a model.

Constructors, destructors, conversion operators

VectorDynSize()
Default constructor: initialize the size of the array to zero.
VectorDynSize(std::size_t _size)
Constructor from the size, all the element assigned to 0.
VectorDynSize(const double* in_data, const std::size_t in_size)
Constructor from a C-style array.
VectorDynSize(const VectorDynSize& vec)
Copy constructor.
VectorDynSize(iDynTree::Span<const double> vec)
Constructor from an iDynTree::Span.
~VectorDynSize() virtual
Denstructor.

Public functions

auto operator=(const VectorDynSize& vec) -> VectorDynSize&
Copy assignment operator.
auto operator=(iDynTree::Span<const double> vec) -> VectorDynSize&
Copy assignment operator.
auto data() const -> const double*
Raw data accessor.
auto data() -> double*
Raw data accessor.
void zero()
Assign all element of the vector to 0.
void reserve(const std::size_t newCapacity)
Increase the capacity of the vector preserving content.
void resize(const std::size_t newSize)
Change the size of the vector preserving old content.
void shrink_to_fit()
Change the capacity of the vector to match the size.
auto capacity() const -> size_t
The buffer pointed by data() has size capacity()*sizeof(double)
void fillBuffer(double* buf) const
Assume that buf is pointing to a buffer of size() doubles, and fill it with the content of this vector.

Protected functions

void changeCapacityAndCopyData(const std::size_t _newCapacity)
Set the capacity of the vector, resizing the buffer pointed by m_data.

Protected variables

double* m_data
Storage for the VectorDynSize.
std::size_t m_size
Size of the vector.
std::size_t m_capacity
The buffer to which m_data is pointing is m_capacity*sizeof(double).

Vector interface methods.

Methods exposing a vector-like interface to PositionRaw.

auto operator()(const std::size_t index) const -> double
auto operator()(const std::size_t index) -> double&
auto operator[](const std::size_t index) const -> double
auto operator[](const std::size_t index) -> double&
auto getVal(const std::size_t index) const -> double
auto setVal(const std::size_t index, const double new_el) -> bool
auto begin() const -> const double* noexcept
Returns a const iterator to the beginning of the vector.
auto end() const -> const double* noexcept
Returns a const iterator to the beginning of the vector.
auto cbegin() const -> const double* noexcept
Returns a const iterator to the beginning of the vector.
auto cend() const -> const double* noexcept
Returns a const iterator to the beginning of the vector.
auto begin() -> double* noexcept
Returns a iterator to the beginning of the vector.
auto end() -> double* noexcept
Returns a iterator to the beginning of the vector.
auto size() const -> std::size_t

Output helpers.

Output helpers.

auto toString() const -> std::string
auto reservedToString() const -> std::string

Function documentation

iDynTree::VectorDynSize::VectorDynSize(std::size_t _size)

Constructor from the size, all the element assigned to 0.

Parameters
_size the desired size of the array.

iDynTree::VectorDynSize::VectorDynSize(const double* in_data, const std::size_t in_size)

Constructor from a C-style array.

Build

iDynTree::VectorDynSize::VectorDynSize(const VectorDynSize& vec)

Copy constructor.

iDynTree::VectorDynSize::VectorDynSize(iDynTree::Span<const double> vec)

Constructor from an iDynTree::Span.

Parameters
vec span representing a vector

iDynTree::VectorDynSize::~VectorDynSize() virtual

Denstructor.

VectorDynSize& iDynTree::VectorDynSize::operator=(const VectorDynSize& vec)

Copy assignment operator.

The vector will be resize to match the size of the argument, and the data will then be copied.

VectorDynSize& iDynTree::VectorDynSize::operator=(iDynTree::Span<const double> vec)

Copy assignment operator.

The vector will be resize to match the size of the argument, and the data will then be copied.

const double* iDynTree::VectorDynSize::data() const

Raw data accessor.

Returns a const pointer to a vector of size() doubles

double* iDynTree::VectorDynSize::data()

Raw data accessor.

Returns a pointer to a vector of size() doubles

void iDynTree::VectorDynSize::reserve(const std::size_t newCapacity)

Increase the capacity of the vector preserving content.

Parameters
newCapacity the new capacity of the vector

void iDynTree::VectorDynSize::resize(const std::size_t newSize)

Change the size of the vector preserving old content.

Parameters
newSize the new size of the vector

void iDynTree::VectorDynSize::shrink_to_fit()

Change the capacity of the vector to match the size.

void iDynTree::VectorDynSize::fillBuffer(double* buf) const

Assume that buf is pointing to a buffer of size() doubles, and fill it with the content of this vector.

Parameters
buf pointer to the buffer to fill

const double* iDynTree::VectorDynSize::begin() const noexcept

Returns a const iterator to the beginning of the vector.

const double* iDynTree::VectorDynSize::end() const noexcept

Returns a const iterator to the beginning of the vector.

const double* iDynTree::VectorDynSize::cbegin() const noexcept

Returns a const iterator to the beginning of the vector.

const double* iDynTree::VectorDynSize::cend() const noexcept

Returns a const iterator to the beginning of the vector.

double* iDynTree::VectorDynSize::begin() noexcept

Returns a iterator to the beginning of the vector.

double* iDynTree::VectorDynSize::end() noexcept

Returns a iterator to the beginning of the vector.

Variable documentation

double* iDynTree::VectorDynSize::m_data protected

Storage for the VectorDynSize.

Pointer to an area of capacity() doubles, managed by this class.