27 #include "../common/STLUtils.h"
45 : m_dimension(rhs.m_dimension),
46 m_dimensionSizes(rhs.m_dimensionSizes),
51 while (it != rhs.
m_data.end())
53 m_data[it->first] = it->second->clone();
73 while (it != rhs.
m_data.end())
75 m_data[it->first] = it->second->clone();
103 assert(i < getDimension());
105 return m_dimensionSizes[i];
110 assert(pos.size() == getDimension());
113 for (std::size_t i = 0; i < getDimension(); i++)
114 m_dimensionSizes[i] = std::max(m_dimensionSizes[i], pos[i] + 1);
124 assert(i.size() == getDimension());
131 assert(i.size() == getDimension());
138 return new Array(*
this);
143 std::ostringstream output;
145 std::size_t total_size = 1;
147 std::vector<std::size_t> products_back (getDimension(), 1);
149 std::vector<std::size_t> products_front (getDimension(), 1);
151 for (std::size_t i = 0; i < getDimension(); i++)
153 total_size *= getDimensionSize(i);
155 for (std::size_t f = i + 1; f < getDimension(); f++)
156 products_front[i] *= getDimensionSize(f);
158 for (std::size_t b = 0; b < i; b++)
159 products_back[i] *= getDimensionSize(b);
162 std::vector<std::vector<std::size_t> > poses(total_size, std::vector<std::size_t>(getDimension(), 0));
164 for (std::size_t ii = 0; ii < getDimension(); ii++)
166 std::size_t i = getDimension() - ii - 1;
169 for (std::size_t j = 0; j < products_back[i]; j++)
170 for (std::size_t k = 0; k < getDimensionSize(i); k++)
171 for (std::size_t l = 0; l < products_front[i]; l++)
177 for (std::size_t i = 0; i < poses.size(); i++)
179 std::map<std::vector<std::size_t>,
te::dt::AbstractData*>::const_iterator it = m_data.find(poses[i]);
181 if(it != m_data.end())
182 output << it->second->
toString() <<
" ";
int m_type
The data type of this array.
V * GetPValue(const std::map< K, V * > &m, const K &k)
It finds for a given key in the map and returns a pointer if something is found or NULL otherwise...
AbstractData * clone() const
It creates a new clone of the array.
std::vector< std::size_t > m_dimensionSizes
The vector of sizes for the dimensions.
int getElementsTypeCode()
Returns the data type of the elements of the array.
Array & operator=(const Array &rhs)
Assignment operator.
virtual std::string toString() const =0
It returns the data value in a string notation.
Class for dealing with arrays of abstract data.
The type for variable-length multidimensional arrays.
std::size_t getDimension() const
Returns the numbe of dimensions of the array.
te::dt::AbstractData & operator[](const std::vector< std::size_t > &i)
Access data in i index.
std::string toString() const
Return a string with all the data inside array.
A base class for values that can be retrieved from the data access module.
std::size_t m_dimension
The number of dimensions.
te::dt::AbstractData * getData(const std::vector< std::size_t > &i)
Returns data from specified position.
Array(std::size_t d, int t)
Multi-dimensional array constructor.
std::size_t getDimensionSize(std::size_t i) const
Gets the number of elements in the i-th dimension.
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...
void insert(te::dt::AbstractData *data, const std::vector< std::size_t > &pos)
Inserts data into specified position.
std::map< std::vector< std::size_t >, te::dt::AbstractData * > m_data
A map from positions to data.