template<typename T>
Vector class
Forward declaration of Vector class.
Vector is a utility class which maps another existing contiguous container.
T is the type of vector (double, float, int, string,...)
It does not contain any data, but only a pointer to an existing contiguous area of memory containing a sequence of objects. It also stores its size, i.e. the number of objects. It does not own this portion of memory, hence it needs to be properly initialized from an existing container, such as an iDynTree::Vector, std::vector, array, yarp::sig::Vector and similar. Even if it does not own the memory, it is possible to resize it. This is done through an user specified lambda, which calls the corresponding "resize" method on the original object from which Vector has been initialized.
Derived classes
- class BipedalLocomotion::GenericContainer::Vector::Ref
- The class ref is used a substitution to a classical reference to a Vector.
Public types
- class Ref
- The class ref is used a substitution to a classical reference to a Vector.
- using vector_element_type = typename iDynTree::Span<T>::element_type
- Utility aliases depending on the type T.
- using value_type = typename iDynTree::Span<T>::value_type
- using index_type = typename iDynTree::Span<T>::index_type
- using pointer = typename iDynTree::Span<T>::pointer
- using reference = typename iDynTree::Span<T>::reference
- using const_reference = const value_type&
- using size_type = typename iDynTree::Span<T>::size_type
- using iterator = typename iDynTree::Span<T>::iterator
- Utility aliases to define iterators.
- using const_iterator = typename iDynTree::Span<T>::const_iterator
- using reverse_iterator = typename iDynTree::Span<T>::reverse_iterator
- using const_reverse_iterator = typename iDynTree::Span<T>::const_reverse_iterator
- using resize_function_type = std::function<iDynTree::Span<T>(index_type)>
- Alias for the type of lambda used to resize the original vector.
- using eigen_map_type = typename Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, 1>>
- Alias to determine the output type of toEigen()
- using eigen_map_const_type = typename Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, 1>>
Constructors, destructors, conversion operators
- Vector() protected defaulted
- The default constructor is private.
-
Vector(iDynTree::Span<T> span,
resize_
function_ type resizeLambda) - Constructor.
- Vector(iDynTree::Span<T> span)
- Constructor.
- ~Vector() defaulted
- Destructor.
- Vector(const Vector<T>& other) deleted
- Copy constructor.
- Vector(Vector<T>&& other)
- Move constructor.
Public functions
- auto clone(const Vector<T>& other) -> bool
- Copies the content of the vector.
- auto clone(iDynTree::Span<T> other) -> bool
- Copies the content of the vector.
- auto operator=(const Vector<T>& other) -> Vector<T>&
- operator = Copies the content
- auto operator=(iDynTree::Span<T> other) -> Vector<T>&
- operator = Copies the content
- auto operator=(Vector<T>&& other) -> Vector<T>&
- Move operator = Copies the content.
- auto resizeVector(index_type newSize) -> bool
- resizeVector It resize the original vector (if possible)
- void resize(index_type newSize)
- resize It resize the original vector (if possible)
- auto size() const -> index_type
- size Get the size of the Vector
- auto empty() const -> bool
- empty Checks if the container is empty (zero size)
- auto operator[](index_type idx) const -> const_reference
- operator [] Accessor
- auto operator[](index_type idx) -> reference
- operator [] Accessor
-
auto getVal(index_type idx) const -> vector_
element_ type - getVal Accessor
-
auto setVal(index_type idx,
vector_
element_ type val) -> bool - setVal Setter
- auto at(index_type idx) const -> const_reference
- at Accessor
- auto at(index_type idx) -> reference
- at Accessor
- auto operator()(index_type idx) const -> const_reference
- operator () Accessor
- auto operator()(index_type idx) -> reference
- operator () Accessor
- auto data() const -> pointer
- data Raw pointer to the data
- auto begin() -> iterator
- begin Iterator
- auto end() -> iterator
- end Iterator
- auto begin() const -> const_iterator
- begin Iterator
- auto end() const -> const_iterator
- end Iterator
- auto cbegin() const -> const_iterator
- cbegin Iterator
- auto cend() const -> const_iterator
- cend Iterator
- auto rbegin() -> reverse_iterator
- rbegin Iterator to the first element of the reversed vector
- auto rend() -> reverse_iterator
- rend Iterator to the element following the last element of the reversed vector.
- auto rbegin() const -> const_reverse_iterator
- rbegin Iterator to the first element of the reversed vector
- auto rend() const -> const_reverse_iterator
- rend Iterator to the element following the last element of the reversed vector.
- auto crbegin() const -> const_reverse_iterator
- crbegin Iterator to the first element of the reversed vector
- auto crend() const -> const_reverse_iterator
- crend Iterator to the element following the last element of the reversed vector.
-
auto toEigen() -> eigen_
map_ type - Get an Eigen map corresponding to the current generic vector (see https://eigen.tuxfamily.org/dox/classEigen_
1_ 1Map.html). - auto toEigen() const -> eigen_map_const_type
- Get an Eigen const map corresponding to the current generic vector (see https://eigen.tuxfamily.org/dox/classEigen_
1_ 1Map.html).
Protected variables
- iDynTree::Span<T> m_span
- Span of the pointed vector.
-
resize_
function_ type m_resizeLambda - User specified lambda to resize the existing container.
Typedef documentation
template<typename T>
using BipedalLocomotion:: GenericContainer:: Vector<T>:: vector_element_type = typename iDynTree::Span<T>::element_type
Utility aliases depending on the type T.
Some notes:
- vector_element_type has a different name than the corresponding one in iDynTree::Span to avoid some compilation issues.
- value_type is the same as vector_element_type, but without an eventual const attribute
template<typename T>
using BipedalLocomotion:: GenericContainer:: Vector<T>:: resize_function_type = std::function<iDynTree::Span<T>(index_type)>
Alias for the type of lambda used to resize the original vector.
In particular, it takes as input the new size (of type index size)
Function documentation
template<typename T>
BipedalLocomotion:: GenericContainer:: Vector<T>:: Vector(iDynTree::Span<T> span,
resize_ function_ type resizeLambda)
Constructor.
Parameters | |
---|---|
span | Span of the existing container |
resizeLambda | User defined lambda to resize the original container |
template<typename T>
BipedalLocomotion:: GenericContainer:: Vector<T>:: Vector(iDynTree::Span<T> span)
Constructor.
Parameters | |
---|---|
span | Span of the existing container |
Since no resizeLambda is provided, it is assumed that the original container cannot be resized.
template<typename T>
bool BipedalLocomotion:: GenericContainer:: Vector<T>:: clone(iDynTree::Span<T> other)
Copies the content of the vector.
Parameters | |
---|---|
other | Span from which to copy |
Returns | true in case of success. False if the two have different size and this is not resizable. |
template<typename T>
bool BipedalLocomotion:: GenericContainer:: Vector<T>:: resizeVector(index_type newSize)
resizeVector It resize the original vector (if possible)
Parameters | |
---|---|
newSize | New size of the vector |
Returns | true if the new size matches the desired. False otherwise. |
template<typename T>
void BipedalLocomotion:: GenericContainer:: Vector<T>:: resize(index_type newSize)
resize It resize the original vector (if possible)
Parameters | |
---|---|
newSize | New size of the vector It calls resizeVector(). There is an assert on its return value. |
template<typename T>
bool BipedalLocomotion:: GenericContainer:: Vector<T>:: empty() const
empty Checks if the container is empty (zero size)
Returns | True if empty. |
---|
template<typename T>
const_reference BipedalLocomotion:: GenericContainer:: Vector<T>:: operator[](index_type idx) const
operator [] Accessor
Parameters | |
---|---|
idx | The index to be accessed |
Returns | A const reference to the requested element. |
template<typename T>
reference BipedalLocomotion:: GenericContainer:: Vector<T>:: operator[](index_type idx)
operator [] Accessor
Parameters | |
---|---|
idx | The index to be accessed |
Returns | A reference to the requested element. |
template<typename T>
vector_ element_ type BipedalLocomotion:: GenericContainer:: Vector<T>:: getVal(index_type idx) const
getVal Accessor
Parameters | |
---|---|
idx | The index to be accessed |
Returns | A const reference to the requested element. |
template<typename T>
bool BipedalLocomotion:: GenericContainer:: Vector<T>:: setVal(index_type idx,
vector_ element_ type val)
setVal Setter
Parameters | |
---|---|
idx | Index of the values to be set |
val | The new value |
Returns | False if idx is not within [0, size()). |
template<typename T>
const_reference BipedalLocomotion:: GenericContainer:: Vector<T>:: at(index_type idx) const
at Accessor
Parameters | |
---|---|
idx | The index to be accessed |
Returns | A const reference to the requested element. |
template<typename T>
reference BipedalLocomotion:: GenericContainer:: Vector<T>:: at(index_type idx)
at Accessor
Parameters | |
---|---|
idx | The index to be accessed |
Returns | A reference to the requested element. |
template<typename T>
const_reference BipedalLocomotion:: GenericContainer:: Vector<T>:: operator()(index_type idx) const
operator () Accessor
Parameters | |
---|---|
idx | The index to be accessed |
Returns | A const reference to the requested element. |
template<typename T>
reference BipedalLocomotion:: GenericContainer:: Vector<T>:: operator()(index_type idx)
operator () Accessor
Parameters | |
---|---|
idx | The index to be accessed |
Returns | A reference to the requested element. |
template<typename T>
pointer BipedalLocomotion:: GenericContainer:: Vector<T>:: data() const
data Raw pointer to the data
Returns | THe raw pointer to the data |
---|
template<typename T>
const_iterator BipedalLocomotion:: GenericContainer:: Vector<T>:: begin() const
begin Iterator
Returns | A const iterator to the end of the sequence |
---|
template<typename T>
const_iterator BipedalLocomotion:: GenericContainer:: Vector<T>:: end() const
end Iterator
Returns | A const iterator to the end of the sequence |
---|
template<typename T>
const_iterator BipedalLocomotion:: GenericContainer:: Vector<T>:: cbegin() const
cbegin Iterator
Returns | A const iterator to the end of the sequence |
---|
template<typename T>
const_iterator BipedalLocomotion:: GenericContainer:: Vector<T>:: cend() const
cend Iterator
Returns | A const iterator to the end of the sequence |
---|
template<typename T>
reverse_iterator BipedalLocomotion:: GenericContainer:: Vector<T>:: rbegin()
rbegin Iterator to the first element of the reversed vector
Returns | Returns a reverse iterator to the first element of the reversed vector. It corresponds to the last element of the non-reversed vector |
---|
template<typename T>
reverse_iterator BipedalLocomotion:: GenericContainer:: Vector<T>:: rend()
rend Iterator to the element following the last element of the reversed vector.
Returns | Returns a reverse iterator to the element following the last element of the reversed vector. It corresponds to the element preceding the first element of the non-reversed vector. |
---|
template<typename T>
const_reverse_iterator BipedalLocomotion:: GenericContainer:: Vector<T>:: rbegin() const
rbegin Iterator to the first element of the reversed vector
Returns | Returns a const reverse iterator to the first element of the reversed vector. It corresponds to the last element of the non-reversed vector |
---|
template<typename T>
const_reverse_iterator BipedalLocomotion:: GenericContainer:: Vector<T>:: rend() const
rend Iterator to the element following the last element of the reversed vector.
Returns | Returns a reverse iterator to the element following the last element of the reversed vector. It corresponds to the element preceding the first element of the non-reversed vector. |
---|
template<typename T>
const_reverse_iterator BipedalLocomotion:: GenericContainer:: Vector<T>:: crbegin() const
crbegin Iterator to the first element of the reversed vector
Returns | Returns a const reverse iterator to the first element of the reversed vector. It corresponds to the last element of the non-reversed vector |
---|
template<typename T>
const_reverse_iterator BipedalLocomotion:: GenericContainer:: Vector<T>:: crend() const
crend Iterator to the element following the last element of the reversed vector.
Returns | Returns a reverse iterator to the element following the last element of the reversed vector. It corresponds to the element preceding the first element of the non-reversed vector. |
---|
Variable documentation
template<typename T>
iDynTree::Span<T> BipedalLocomotion:: GenericContainer:: Vector<T>:: m_span protected
Span of the pointed vector.
This allows to point to an existing container without owning it.