VISR  0.12.0
Versatile Interactive Scene Renderer
visr::efl::BasicVector< ElementType > Class Template Reference

#include <basic_vector.hpp>

Inheritance diagram for visr::efl::BasicVector< ElementType >:
visr::pml::VectorParameter< ElementType >

Public Member Functions

 BasicVector (std::size_t alignmentElements=0)
 
 BasicVector (std::size_t size, std::size_t alignmentElements)
 
 BasicVector (std::initializer_list< ElementType > const &initialValues, std::size_t alignmentElements=0)
 
 BasicVector (BasicVector< ElementType > &&rhs)=default
 
BasicVector< ElementType > & operator= (BasicVector< ElementType > &&rhs)=default
 
 ~BasicVector ()
 
void resize (std::size_t newSize)
 
void assign (const BasicVector< ElementType > &rhs)
 
void zeroFill ()
 
void fillValue (ElementType val)
 
void swap (BasicVector< ElementType > &rhs)
 
void copy (BasicVector< ElementType > const &rhs)
 
std::size_t alignmentElements () const
 
std::size_t size () const
 
ElementType & operator[] (std::size_t idx)
 
ElementType const & operator[] (std::size_t idx) const
 
ElementType & at (std::size_t idx)
 
ElementType const & at (std::size_t idx) const
 
ElementType * data ()
 
ElementType const * data () const
 

Detailed Description

template<typename ElementType>
class visr::efl::BasicVector< ElementType >

Basic numeric vector type with comprehensive access functions, but little arithmetic functionality. Such functions should be added as free functions (probably as wrappers around the vector functions implemented in libefl

Constructor & Destructor Documentation

◆ BasicVector() [1/4]

template<typename ElementType>
visr::efl::BasicVector< ElementType >::BasicVector ( std::size_t  alignmentElements = 0)
inlineexplicit

Construct an empty vector.

Parameters
alignmentElementsThe alignment of the array, given as a multiple of the element size.

◆ BasicVector() [2/4]

template<typename ElementType>
visr::efl::BasicVector< ElementType >::BasicVector ( std::size_t  size,
std::size_t  alignmentElements 
)
inlineexplicit

Construct a vector with a given size. The elements are initialized to the zero element of the vector's data type.

Parameters
sizeThe number of elements.
alignmentElementsThe alignment of the array, given as a multiple of the element size.

◆ BasicVector() [3/4]

template<typename ElementType>
visr::efl::BasicVector< ElementType >::BasicVector ( std::initializer_list< ElementType > const &  initialValues,
std::size_t  alignmentElements = 0 
)
inlineexplicit

Construct a vector from a static initialiser list. This constructor is mainly used to initialise a vector from a values represented in the source code. The size of the vector is determined from the number of elements in initialValues.

Parameters
initialValuesThe vector elements represented by a list in curly braces.
alignmentElementsThe alignment of the array, given as a multiple of the element size.

◆ BasicVector() [4/4]

template<typename ElementType>
visr::efl::BasicVector< ElementType >::BasicVector ( BasicVector< ElementType > &&  rhs)
default

◆ ~BasicVector()

template<typename ElementType>
visr::efl::BasicVector< ElementType >::~BasicVector ( )
inline

Destructor.

Member Function Documentation

◆ alignmentElements()

template<typename ElementType>
std::size_t visr::efl::BasicVector< ElementType >::alignmentElements ( ) const
inline

Query the alignment of the vector data as specified in the constructor.

Returns
The alignment as a multiple of the element size.

◆ assign()

template<typename ElementType>
void visr::efl::BasicVector< ElementType >::assign ( const BasicVector< ElementType > &  rhs)
inline

Explicit assignment function. Resizes the vector to the size of rhs and copies the content.

Parameters
rhsVector to be copied.

◆ at() [1/2]

template<typename ElementType>
ElementType& visr::efl::BasicVector< ElementType >::at ( std::size_t  idx)
inline

Index access to an element of the array. This version returns a non-const reference that can be used to alter the value.

See also
operator[]
Parameters
idxA zero-offset vector index.
Returns
A non-constant reference to the vector element indexed by idx
Exceptions
std::out_of_rangeIf idx exceeds the size of the vector.

◆ at() [2/2]

template<typename ElementType>
ElementType const& visr::efl::BasicVector< ElementType >::at ( std::size_t  idx) const
inline

Index access to an element of the array. This const version returns a non-const reference.

See also
operator[]
Parameters
idxA zero-offset vector index.
Returns
A constant reference to the vector element indexed by idx
Exceptions
std::out_of_rangeIf idx exceeds the size of the vector.

◆ copy()

template<typename ElementType>
void visr::efl::BasicVector< ElementType >::copy ( BasicVector< ElementType > const &  rhs)
inline

Copy the content of Vector.

Parameters
rhsThe Vector to be copied.
Exceptions
std::invalid_argumentif the size of rhs does not match this Vector.

◆ data() [1/2]

template<typename ElementType>
ElementType* visr::efl::BasicVector< ElementType >::data ( )
inline

Gain access to the vector's raw data.

Returns
A non-const pointer to the first (i.e., zeroth) element.

◆ data() [2/2]

template<typename ElementType>
ElementType const* visr::efl::BasicVector< ElementType >::data ( ) const
inline

Gain access to the vector's raw data (const version)

Returns
A const pointer to the first (i.e., zeroth) element.

◆ fillValue()

template<typename ElementType>
void visr::efl::BasicVector< ElementType >::fillValue ( ElementType  val)
inline

Set all elements of the vector to the same value.

Parameters
valThe new value of all vector elements.
Exceptions
std::runtime_errorIf an arithmetic error occurs.

◆ operator=()

template<typename ElementType>
BasicVector<ElementType>& visr::efl::BasicVector< ElementType >::operator= ( BasicVector< ElementType > &&  rhs)
default

◆ operator[]() [1/2]

template<typename ElementType>
ElementType& visr::efl::BasicVector< ElementType >::operator[] ( std::size_t  idx)
inline

Index access to an element of the array. This version returns a non-const reference that can be used to alter the value.

Note
This operator does not perform bounds checking, use at() for this
See also
at()
Parameters
idxA zero-offset vector index.
Returns
A non-constant reference to the vector element indexed by idx

◆ operator[]() [2/2]

template<typename ElementType>
ElementType const& visr::efl::BasicVector< ElementType >::operator[] ( std::size_t  idx) const
inline

Index access to an element of the array. This is the const version which returns a const reference,

Note
This operator does not perform bounds checking, use at() for this feature
See also
at()
Parameters
idxA zero-offset vector index.
Returns
A non-constant reference to the vector element indexed by idx

◆ resize()

template<typename ElementType>
void visr::efl::BasicVector< ElementType >::resize ( std::size_t  newSize)
inline

Reset the size of the vector. All elements will be reset to zero.

Parameters
newSizeThe new size (in elements)

◆ size()

template<typename ElementType>
std::size_t visr::efl::BasicVector< ElementType >::size ( ) const
inline

Query the size of the vector.

Returns
The number of elements.

◆ swap()

template<typename ElementType>
void visr::efl::BasicVector< ElementType >::swap ( BasicVector< ElementType > &  rhs)
inline

Swap the contents with a vector of a consistent layout.

Parameters
rhsThe Vector to be swapped with.
Exceptions
std::logic_errorif the vector layouts, i.e., number of rows or columns, stride or alignment, are inconsistent.

◆ zeroFill()

template<typename ElementType>
void visr::efl::BasicVector< ElementType >::zeroFill ( )
inline

Set the vector elements to the zero element of the data type template parameter.

Exceptions
std::runtime_errorIf an arithmetic error occurs.

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