libtad  2.1
A library that makes working with multidimensional arrays in C++ easy
Classes | List of all members
TAD::Array< T > Class Template Reference

An Array with a specific component data type given the template parameter. This is the main class to work with since it allows useful for operations on arrays (e.g. component-wise addition) and provides iterators. More...

Inherits TAD::ArrayContainer.

Classes

class  ComponentIterator
 Iterator over all components in the array. This is a random access iterator. More...
 
class  ConstComponentIterator
 Const iterator over all components in the array. This is a random access iterator. More...
 
class  ConstElementIterator
 Const iterator over all elements in the array. When dereferenced, this returns a pointer to the components of an element. This is a random access iterator. More...
 
class  ElementIterator
 Iterator over all elements in the array. When dereferenced, this returns a pointer to the components of an element. This is a random access iterator. More...
 

Public Member Functions

Constructors etc
 Array ()
 Constructor for an empty array. More...
 
 Array (const std::vector< size_t > &dimensions, size_t components)
 Constructor for an array. More...
 
 Array (const ArrayDescription &desc)
 Constructor for an array. More...
 
 Array (const ArrayContainer &container)
 Constructor for an array. More...
 
Array deepCopy () const
 Construct an array and perform deep copy of data. More...
 
Iterators
ComponentIterator componentBegin () noexcept
 Returns an iterator pointing to the first component of the first element. More...
 
ComponentIterator componentEnd () noexcept
 Returns an iterator pointing past the last component of the last element. More...
 
ElementIterator elementBegin () noexcept
 Returns an iterator pointing to the first element. More...
 
ElementIterator elementEnd () noexcept
 Returns an iterator pointing past the last element. More...
 
ConstComponentIterator constComponentBegin () const noexcept
 Returns an iterator pointing to the first component of the first element. More...
 
ConstComponentIterator constComponentEnd () const noexcept
 Returns an iterator pointing past the last component of the last element. More...
 
ConstElementIterator constElementBegin () const noexcept
 Returns an iterator pointing to the first element. More...
 
ConstElementIterator constElementEnd () const noexcept
 Returns an iterator pointing past the last element. More...
 
Data access
const T * operator[] (size_t elementIndex) const
 Returns a pointer to the element with index elementIndex. More...
 
const T * operator[] (const std::vector< size_t > &elementIndex) const
 Returns a pointer to the element with index elementIndex. More...
 
const T * operator[] (const std::initializer_list< size_t > &elementIndex) const
 Returns a pointer to the element with index elementIndex. More...
 
T * operator[] (size_t elementIndex)
 Returns a pointer to the element with index elementIndex. More...
 
T * operator[] (const std::vector< size_t > &elementIndex)
 Returns a pointer to the element with index elementIndex. More...
 
T * operator[] (const std::initializer_list< size_t > &elementIndex)
 Returns a pointer to the element with index elementIndex. More...
 
- Public Member Functions inherited from TAD::ArrayContainer
 ArrayContainer ()
 Constructor for an empty array container. More...
 
 ArrayContainer (const ArrayDescription &desc)
 Constructor for an array container. More...
 
 ArrayContainer (const std::vector< size_t > &dimensions, size_t components, Type componentType)
 Constructor for an array container. More...
 
ArrayContainer deepCopy () const
 Construct an array and perform deep copy of data. More...
 
const void * data () const
 Returns a pointer to the data. This will return a null pointer as long as the data was not allocated yet; see allocateData(). More...
 
void * data ()
 Returns a pointer to the data. This will return a null pointer as long as the data was not allocated yet; see allocateData(). More...
 
template<typename T >
const T * get (size_t elementIndex) const
 Returns a pointer to the element with index elementIndex. Note that the data must be allocated, see createData(). More...
 
template<typename T >
const T * get (const std::vector< size_t > &elementIndex) const
 Returns a pointer to the element with index elementIndex. Note that the data must be allocated, see createData(). More...
 
template<typename T >
const T * get (const std::initializer_list< size_t > &elementIndex) const
 Returns a pointer to the element with index elementIndex. Note that the data must be allocated, see createData(). More...
 
template<typename T >
T * get (size_t elementIndex)
 Returns a pointer to the element with index elementIndex. Note that the data must be allocated, see createData(). More...
 
template<typename T >
T * get (const std::vector< size_t > &elementIndex)
 Returns a pointer to the element with index elementIndex. Note that the data must be allocated, see createData(). More...
 
template<typename T >
T * get (const std::initializer_list< size_t > &elementIndex)
 Returns a pointer to the element with index elementIndex. Note that the data must be allocated, see createData(). More...
 
template<typename T >
void set (size_t elementIndex, const std::vector< T > &elementValue)
 Sets the components of the element with index elementIndex to the given values. More...
 
template<typename T >
void set (size_t elementIndex, const std::initializer_list< T > &elementValue)
 Sets the components of the element with index elementIndex to the given values. More...
 
template<typename T >
void set (const std::vector< size_t > &elementIndex, const std::vector< T > &elementValue)
 Sets the components of the element with index elementIndex to the given values. More...
 
template<typename T >
void set (const std::vector< size_t > &elementIndex, const std::initializer_list< T > &elementValue)
 Sets the components of the element with index elementIndex to the given values. More...
 
template<typename T >
void set (const std::initializer_list< size_t > &elementIndex, const std::vector< T > &elementValue)
 Sets the components of the element with index elementIndex to the given values. More...
 
template<typename T >
void set (const std::initializer_list< size_t > &elementIndex, const std::initializer_list< T > &elementValue)
 Sets the components of the element with index elementIndex to the given values. More...
 
template<typename T >
get (size_t elementIndex, size_t componentIndex) const
 Returns the value of the component with index componentIndex within the element with index elementIndex. More...
 
template<typename T >
get (const std::vector< size_t > &elementIndex, size_t componentIndex) const
 Returns the value of the component with index componentIndex within the element with index elementIndex. More...
 
template<typename T >
get (const std::initializer_list< size_t > &elementIndex, size_t componentIndex) const
 Returns the value of the component with index componentIndex within the element with index elementIndex. More...
 
template<typename T >
void set (size_t elementIndex, size_t componentIndex, T value)
 Sets the component with index componentIndex within the element with index elementIndex to value. More...
 
template<typename T >
void set (const std::vector< size_t > &elementIndex, size_t componentIndex, T value)
 Sets the component with index componentIndex within the element with index elementIndex to value. More...
 
template<typename T >
void set (const std::initializer_list< size_t > &elementIndex, size_t componentIndex, T value)
 Sets the component with index componentIndex within the element with index elementIndex to value. More...
 
- Public Member Functions inherited from TAD::ArrayDescription
 ArrayDescription ()
 Constructor for an empty array description. More...
 
 ArrayDescription (const std::vector< size_t > &dimensions, size_t componentCount, Type componentType)
 Constructor for an array description. More...
 
 ArrayDescription (const ArrayDescription &descr, Type type)
 Constructor for an array description. More...
 
size_t dimensionCount () const
 Returns the number of dimensions. More...
 
size_t dimension (size_t d) const
 Returns the size of dimension d. More...
 
const std::vector< size_t > & dimensions () const
 Returns the list of dimensions. More...
 
size_t componentCount () const
 Returns the number of components in each element. More...
 
Type componentType () const
 Returns the type represented by each element component. More...
 
size_t componentSize () const
 Returns the size of a component. More...
 
size_t elementSize () const
 Returns the size of an element. More...
 
size_t elementCount () const
 Returns the number of elements in the array. More...
 
size_t dataSize () const
 Returns the total data size. More...
 
bool isCompatible (const ArrayDescription &a) const
 Returns whether the dimensions and components of array match those of this array. More...
 
const ArrayDescriptiondescription () const
 Returns this as a description. This is useful for derived classes. More...
 
size_t toLinearIndex (const std::vector< size_t > &elementIndex) const
 Convert the given multidimensional element index to a linear element index. For example, for a 800x600 array, the multidimensional index { 1, 1 } is converted to linear index 601. More...
 
size_t toLinearIndex (const std::initializer_list< size_t > &elementIndex) const
 Convert the given multidimensional element index to a linear element index. For example, for a 800x600 array, the multidimensional index { 1, 1 } is converted to linear index 601. More...
 
void toVectorIndex (size_t elementIndex, size_t *vectorIndex) const
 Convert the given linear element index to a multidimensional index. For example, for a 800x600 array, the linear index 601 is converted to the multidimensional index { 1, 1 }. More...
 
size_t elementOffset (size_t elementIndex) const
 Returns the offset of the element with index elementIndex within the data. More...
 
size_t elementOffset (const std::vector< size_t > &elementIndex) const
 Returns the offset of the element with index elementIndex within the data. More...
 
size_t elementOffset (const std::initializer_list< size_t > &elementIndex) const
 Returns the offset of the element with index elementIndex within the data. More...
 
size_t componentOffset (size_t componentIndex) const
 Returns the offset of the component with index componentIndex within an array element. More...
 
size_t componentOffset (size_t elementIndex, size_t componentIndex) const
 Returns the offset of the component with index componentIndex in the element with index elementIndex within an array element. More...
 
size_t componentOffset (const std::vector< size_t > &elementIndex, size_t componentIndex) const
 Returns the offset of the component with index componentIndex in the element with index elementIndex within an array element. More...
 
size_t componentOffset (const std::initializer_list< size_t > &elementIndex, size_t componentIndex) const
 Returns the offset of the component with index componentIndex in the element with index elementIndex within an array element. More...
 
const TagListglobalTagList () const
 Returns the global tag list. More...
 
TagListglobalTagList ()
 Returns the global tag list. More...
 
const TagListdimensionTagList (size_t d) const
 Returns the tag list for dimension d. More...
 
TagListdimensionTagList (size_t d)
 Returns the tag list for dimension d. More...
 
const TagListcomponentTagList (size_t c) const
 Returns the tag list for component c. More...
 
TagListcomponentTagList (size_t c)
 Returns the tag list for component c. More...
 

Detailed Description

template<typename T>
class TAD::Array< T >

An Array with a specific component data type given the template parameter. This is the main class to work with since it allows useful for operations on arrays (e.g. component-wise addition) and provides iterators.

Constructor & Destructor Documentation

◆ Array() [1/4]

template<typename T >
TAD::Array< T >::Array ( )
inline

Constructor for an empty array.

◆ Array() [2/4]

template<typename T >
TAD::Array< T >::Array ( const std::vector< size_t > &  dimensions,
size_t  components 
)
inlineexplicit

Constructor for an array.

◆ Array() [3/4]

template<typename T >
TAD::Array< T >::Array ( const ArrayDescription desc)
inlineexplicit

Constructor for an array.

◆ Array() [4/4]

template<typename T >
TAD::Array< T >::Array ( const ArrayContainer container)
inline

Constructor for an array.

Member Function Documentation

◆ componentBegin()

template<typename T >
ComponentIterator TAD::Array< T >::componentBegin ( )
inlinenoexcept

Returns an iterator pointing to the first component of the first element.

◆ componentEnd()

template<typename T >
ComponentIterator TAD::Array< T >::componentEnd ( )
inlinenoexcept

Returns an iterator pointing past the last component of the last element.

◆ constComponentBegin()

template<typename T >
ConstComponentIterator TAD::Array< T >::constComponentBegin ( ) const
inlinenoexcept

Returns an iterator pointing to the first component of the first element.

◆ constComponentEnd()

template<typename T >
ConstComponentIterator TAD::Array< T >::constComponentEnd ( ) const
inlinenoexcept

Returns an iterator pointing past the last component of the last element.

◆ constElementBegin()

template<typename T >
ConstElementIterator TAD::Array< T >::constElementBegin ( ) const
inlinenoexcept

Returns an iterator pointing to the first element.

◆ constElementEnd()

template<typename T >
ConstElementIterator TAD::Array< T >::constElementEnd ( ) const
inlinenoexcept

Returns an iterator pointing past the last element.

◆ deepCopy()

template<typename T >
Array TAD::Array< T >::deepCopy ( ) const
inline

Construct an array and perform deep copy of data.

◆ elementBegin()

template<typename T >
ElementIterator TAD::Array< T >::elementBegin ( )
inlinenoexcept

Returns an iterator pointing to the first element.

◆ elementEnd()

template<typename T >
ElementIterator TAD::Array< T >::elementEnd ( )
inlinenoexcept

Returns an iterator pointing past the last element.

◆ operator[]() [1/6]

template<typename T >
T* TAD::Array< T >::operator[] ( const std::initializer_list< size_t > &  elementIndex)
inline

Returns a pointer to the element with index elementIndex.

◆ operator[]() [2/6]

template<typename T >
const T* TAD::Array< T >::operator[] ( const std::initializer_list< size_t > &  elementIndex) const
inline

Returns a pointer to the element with index elementIndex.

◆ operator[]() [3/6]

template<typename T >
T* TAD::Array< T >::operator[] ( const std::vector< size_t > &  elementIndex)
inline

Returns a pointer to the element with index elementIndex.

◆ operator[]() [4/6]

template<typename T >
const T* TAD::Array< T >::operator[] ( const std::vector< size_t > &  elementIndex) const
inline

Returns a pointer to the element with index elementIndex.

◆ operator[]() [5/6]

template<typename T >
T* TAD::Array< T >::operator[] ( size_t  elementIndex)
inline

Returns a pointer to the element with index elementIndex.

◆ operator[]() [6/6]

template<typename T >
const T* TAD::Array< T >::operator[] ( size_t  elementIndex) const
inline

Returns a pointer to the element with index elementIndex.


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