All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
te::dt::Array Class Reference

The type for variable-length multidimensional arrays. More...

#include <Array.h>

Inheritance diagram for te::dt::Array:
te::dt::AbstractData

Public Member Functions

 Array (std::size_t d, int t)
 Multi-dimensional array constructor. More...
 
 Array (const Array &rhs)
 Copy constructor. More...
 
AbstractDataclone () const
 It creates a new clone of the array. More...
 
te::dt::AbstractDatagetData (const std::vector< std::size_t > &i)
 Returns data from specified position. More...
 
std::size_t getDimension () const
 Returns the numbe of dimensions of the array. More...
 
std::size_t getDimensionSize (std::size_t i) const
 Gets the number of elements in the i-th dimension. More...
 
int getElementsTypeCode ()
 Returns the data type of the elements of the array. More...
 
int getTypeCode () const
 Returns the type code for array data: ARRAY_TYPE. More...
 
void insert (te::dt::AbstractData *data, const std::vector< std::size_t > &pos)
 Inserts data into specified position. More...
 
Arrayoperator= (const Array &rhs)
 Assignment operator. More...
 
te::dt::AbstractDataoperator[] (const std::vector< std::size_t > &i)
 Access data in i index. More...
 
std::string toString () const
 Return a string with all the data inside array. More...
 
 ~Array ()
 Destructor. More...
 

Protected Attributes

std::map< std::vector
< std::size_t >
, te::dt::AbstractData * > 
m_data
 A map from positions to data. More...
 
std::size_t m_dimension
 The number of dimensions. More...
 
std::vector< std::size_t > m_dimensionSizes
 The vector of sizes for the dimensions. More...
 
int m_type
 The data type of this array. More...
 

Detailed Description

The type for variable-length multidimensional arrays.

Note
This class was not designed to achieve performance, since it maps a vector of positions to one abstract data. This class is only a container to be used by database drivers. If you need a high performance array class with matrix operations, see the Matrix module. To access the data, you must define a vector of positions, where each dimension in the vector corresponds to the respective dimension in the array.
See also
ArrayProperty, AbstractData

Definition at line 59 of file Array.h.

Constructor & Destructor Documentation

te::dt::Array::Array ( std::size_t  d,
int  t 
)

Multi-dimensional array constructor.

Parameters
dThe number of dimensions of the array.
tThe data type.

Definition at line 36 of file Array.cpp.

References m_dimension, and m_dimensionSizes.

te::dt::Array::Array ( const Array rhs)

Copy constructor.

Parameters
rhsThe right-hand-side instance.

Definition at line 44 of file Array.cpp.

References m_data.

te::dt::Array::~Array ( )

Destructor.

Definition at line 86 of file Array.cpp.

References te::common::FreeContents().

Member Function Documentation

te::dt::AbstractData * te::dt::Array::clone ( ) const
virtual

It creates a new clone of the array.

Returns
A new clone of the array. The caller will take its ownership.

Implements te::dt::AbstractData.

Definition at line 136 of file Array.cpp.

te::dt::AbstractData * te::dt::Array::getData ( const std::vector< std::size_t > &  i)

Returns data from specified position.

Parameters
iThe position in the array to get data (d1, d2, ... dn).
Returns
The data from specified position.

Definition at line 122 of file Array.cpp.

References te::common::GetPValue().

std::size_t te::dt::Array::getDimension ( ) const

Returns the numbe of dimensions of the array.

Definition at line 91 of file Array.cpp.

std::size_t te::dt::Array::getDimensionSize ( std::size_t  i) const

Gets the number of elements in the i-th dimension.

Parameters
iThe dimension index.
Returns
The number of elements in the i-th dimension.

Definition at line 101 of file Array.cpp.

int te::dt::Array::getElementsTypeCode ( )

Returns the data type of the elements of the array.

Note
The attribute types are listed in terralib/datatype/DataTypes.h

Definition at line 96 of file Array.cpp.

int te::dt::Array::getTypeCode ( ) const
inlinevirtual

Returns the type code for array data: ARRAY_TYPE.

Implements te::dt::AbstractData.

Definition at line 144 of file Array.h.

References te::dt::ARRAY_TYPE.

void te::dt::Array::insert ( te::dt::AbstractData data,
const std::vector< std::size_t > &  pos 
)

Inserts data into specified position.

Parameters
dataThe data to be inserted.
posThe position in the array to insert data (d1, d2, ... dn).

Definition at line 108 of file Array.cpp.

te::dt::Array & te::dt::Array::operator= ( const Array rhs)

Assignment operator.

Parameters
rhsThe right-hand-side instance.
Returns
A reference to this array.

Definition at line 59 of file Array.cpp.

References te::common::FreeContents(), m_data, m_dimension, m_dimensionSizes, and m_type.

te::dt::AbstractData & te::dt::Array::operator[] ( const std::vector< std::size_t > &  i)

Access data in i index.

Parameters
iThe data index, a vector of std::size_t.
Warning
The caller is reponsible for providing a valid index.
Returns
A reference to the i-th data.

Definition at line 129 of file Array.cpp.

References te::common::GetPValue().

std::string te::dt::Array::toString ( void  ) const
virtual

Return a string with all the data inside array.

Implements te::dt::AbstractData.

Definition at line 141 of file Array.cpp.

References te::dt::AbstractData::toString().

Member Data Documentation

std::map<std::vector<std::size_t>, te::dt::AbstractData*> te::dt::Array::m_data
protected

A map from positions to data.

Definition at line 151 of file Array.h.

Referenced by Array(), and operator=().

std::size_t te::dt::Array::m_dimension
protected

The number of dimensions.

Definition at line 152 of file Array.h.

Referenced by Array(), and operator=().

std::vector<std::size_t> te::dt::Array::m_dimensionSizes
protected

The vector of sizes for the dimensions.

Definition at line 153 of file Array.h.

Referenced by Array(), and operator=().

int te::dt::Array::m_type
protected

The data type of this array.

Definition at line 154 of file Array.h.

Referenced by operator=().


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