libtgd 5.0
A library that makes working with multidimensional arrays in C++ easy
TGD::ArrayContainer Class Reference

The ArrayContainer class manages arrays with arbitrary component data types. More...

#include <array.hpp>

Inherits TGD::ArrayDescription.

Inherited by TGD::Array< T >.

Public Member Functions

Constructors / Destructor
 ArrayContainer ()
 Constructor for an empty array container.
 ArrayContainer (const ArrayDescription &desc, const Allocator &alloc=Allocator())
 Constructor for an array container.
 ArrayContainer (const std::vector< size_t > &dimensions, size_t components, Type componentType, const Allocator &alloc=Allocator())
 Constructor for an array container.
ArrayContainer deepCopy (const Allocator &alloc=Allocator()) const
 Construct an array and perform deep copy of data.
Data access
const void * data () const
 Returns a pointer to the data.
void * data ()
 Returns a pointer to the data.
template<typename T>
const T * get (size_t elementIndex) const
 Returns a pointer to the element with index elementIndex.
template<typename T>
const T * get (const std::vector< size_t > &elementIndex) const
 Returns a pointer to the element with index elementIndex.
template<typename T>
const T * get (const std::initializer_list< size_t > &elementIndex) const
 Returns a pointer to the element with index elementIndex.
template<typename T>
T * get (size_t elementIndex)
 Returns a pointer to the element with index elementIndex.
template<typename T>
T * get (const std::vector< size_t > &elementIndex)
 Returns a pointer to the element with index elementIndex.
template<typename T>
T * get (const std::initializer_list< size_t > &elementIndex)
 Returns a pointer to the element with index elementIndex.
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.
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.
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.
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.
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.
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.
template<typename T>
T get (size_t elementIndex, size_t componentIndex) const
 Returns the value of the component with index componentIndex within the element with index elementIndex.
template<typename T>
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.
template<typename T>
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.
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.
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.
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.
Public Member Functions inherited from TGD::ArrayDescription
 ArrayDescription ()
 Constructor for an empty array description.
 ArrayDescription (const std::vector< size_t > &dimensions, size_t componentCount, Type componentType)
 Constructor for an array description.
 ArrayDescription (const ArrayDescription &descr, Type type)
 Constructor for an array description.
size_t dimensionCount () const
 Returns the number of dimensions.
size_t dimension (size_t d) const
 Returns the size of dimension d.
const std::vector< size_t > & dimensions () const
 Returns the list of dimensions.
size_t componentCount () const
 Returns the number of components in each element.
Type componentType () const
 Returns the type represented by each element component.
size_t componentSize () const
 Returns the size of a component.
size_t elementSize () const
 Returns the size of an element.
size_t elementCount () const
 Returns the number of elements in the array.
size_t dataSize () const
 Returns the total data size.
bool isCompatible (const ArrayDescription &a) const
 Returns whether the dimensions and components of array match those of this array.
const ArrayDescription & description () const
 Returns this as a description. This is useful for derived classes.
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.
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.
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 }.
size_t elementOffset (size_t elementIndex) const
 Returns the offset of the element with index elementIndex within the data.
size_t elementOffset (const std::vector< size_t > &elementIndex) const
 Returns the offset of the element with index elementIndex within the data.
size_t elementOffset (const std::initializer_list< size_t > &elementIndex) const
 Returns the offset of the element with index elementIndex within the data.
size_t componentOffset (size_t componentIndex) const
 Returns the offset of the component with index componentIndex within an array element.
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.
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.
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.
const TagList & globalTagList () const
 Returns the global tag list.
TagList & globalTagList ()
 Returns the global tag list.
const TagList & dimensionTagList (size_t d) const
 Returns the tag list for dimension d.
TagList & dimensionTagList (size_t d)
 Returns the tag list for dimension d.
const TagList & componentTagList (size_t c) const
 Returns the tag list for component c.
TagList & componentTagList (size_t c)
 Returns the tag list for component c.

Detailed Description

The ArrayContainer class manages arrays with arbitrary component data types.

Constructor & Destructor Documentation

◆ ArrayContainer() [1/3]

TGD::ArrayContainer::ArrayContainer ( )
inline

Constructor for an empty array container.

◆ ArrayContainer() [2/3]

TGD::ArrayContainer::ArrayContainer ( const ArrayDescription & desc,
const Allocator & alloc = Allocator() )
inline

Constructor for an array container.

◆ ArrayContainer() [3/3]

TGD::ArrayContainer::ArrayContainer ( const std::vector< size_t > & dimensions,
size_t components,
Type componentType,
const Allocator & alloc = Allocator() )
inline

Constructor for an array container.

Member Function Documentation

◆ data() [1/2]

void * TGD::ArrayContainer::data ( )
inline

Returns a pointer to the data.

◆ data() [2/2]

const void * TGD::ArrayContainer::data ( ) const
inline

Returns a pointer to the data.

◆ deepCopy()

ArrayContainer TGD::ArrayContainer::deepCopy ( const Allocator & alloc = Allocator()) const
inline

Construct an array and perform deep copy of data.

◆ get() [1/9]

template<typename T>
T * TGD::ArrayContainer::get ( const std::initializer_list< size_t > & elementIndex)
inline

Returns a pointer to the element with index elementIndex.

◆ get() [2/9]

template<typename T>
const T * TGD::ArrayContainer::get ( const std::initializer_list< size_t > & elementIndex) const
inline

Returns a pointer to the element with index elementIndex.

◆ get() [3/9]

template<typename T>
T TGD::ArrayContainer::get ( const std::initializer_list< size_t > & elementIndex,
size_t componentIndex ) const
inline

Returns the value of the component with index componentIndex within the element with index elementIndex.

◆ get() [4/9]

template<typename T>
T * TGD::ArrayContainer::get ( const std::vector< size_t > & elementIndex)
inline

Returns a pointer to the element with index elementIndex.

◆ get() [5/9]

template<typename T>
const T * TGD::ArrayContainer::get ( const std::vector< size_t > & elementIndex) const
inline

Returns a pointer to the element with index elementIndex.

◆ get() [6/9]

template<typename T>
T TGD::ArrayContainer::get ( const std::vector< size_t > & elementIndex,
size_t componentIndex ) const
inline

Returns the value of the component with index componentIndex within the element with index elementIndex.

◆ get() [7/9]

template<typename T>
T * TGD::ArrayContainer::get ( size_t elementIndex)
inline

Returns a pointer to the element with index elementIndex.

◆ get() [8/9]

template<typename T>
const T * TGD::ArrayContainer::get ( size_t elementIndex) const
inline

Returns a pointer to the element with index elementIndex.

◆ get() [9/9]

template<typename T>
T TGD::ArrayContainer::get ( size_t elementIndex,
size_t componentIndex ) const
inline

Returns the value of the component with index componentIndex within the element with index elementIndex.

◆ set() [1/9]

template<typename T>
void TGD::ArrayContainer::set ( const std::initializer_list< size_t > & elementIndex,
const std::initializer_list< T > & elementValue )
inline

Sets the components of the element with index elementIndex to the given values.

◆ set() [2/9]

template<typename T>
void TGD::ArrayContainer::set ( const std::initializer_list< size_t > & elementIndex,
const std::vector< T > & elementValue )
inline

Sets the components of the element with index elementIndex to the given values.

◆ set() [3/9]

template<typename T>
void TGD::ArrayContainer::set ( const std::initializer_list< size_t > & elementIndex,
size_t componentIndex,
T value )
inline

Sets the component with index componentIndex within the element with index elementIndex to value.

◆ set() [4/9]

template<typename T>
void TGD::ArrayContainer::set ( const std::vector< size_t > & elementIndex,
const std::initializer_list< T > & elementValue )
inline

Sets the components of the element with index elementIndex to the given values.

◆ set() [5/9]

template<typename T>
void TGD::ArrayContainer::set ( const std::vector< size_t > & elementIndex,
const std::vector< T > & elementValue )
inline

Sets the components of the element with index elementIndex to the given values.

◆ set() [6/9]

template<typename T>
void TGD::ArrayContainer::set ( const std::vector< size_t > & elementIndex,
size_t componentIndex,
T value )
inline

Sets the component with index componentIndex within the element with index elementIndex to value.

◆ set() [7/9]

template<typename T>
void TGD::ArrayContainer::set ( size_t elementIndex,
const std::initializer_list< T > & elementValue )
inline

Sets the components of the element with index elementIndex to the given values.

◆ set() [8/9]

template<typename T>
void TGD::ArrayContainer::set ( size_t elementIndex,
const std::vector< T > & elementValue )
inline

Sets the components of the element with index elementIndex to the given values.

◆ set() [9/9]

template<typename T>
void TGD::ArrayContainer::set ( size_t elementIndex,
size_t componentIndex,
T value )
inline

Sets the component with index componentIndex within the element with index elementIndex to value.


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