28#ifndef __MDDS_MULTI_TYPE_MATRIX_HPP__
29#define __MDDS_MULTI_TYPE_MATRIX_HPP__
31#ifdef MDDS_MULTI_TYPE_MATRIX_DEBUG
32#ifndef MDDS_MULTI_TYPE_VECTOR_DEBUG
33#define MDDS_MULTI_TYPE_VECTOR_DEBUG 1
37#include "multi_type_vector.hpp"
48 element_empty = mdds::mtv::element_type_empty,
49 element_boolean = mdds::mtv::element_type_boolean,
50 element_string = mdds::mtv::element_type_string,
51 element_numeric = mdds::mtv::element_type_double,
52 element_integer = mdds::mtv::element_type_int32
75template<
typename Traits>
78 typedef Traits traits_type;
81 typedef typename traits_type::string_element_block string_block_type;
82 typedef typename traits_type::integer_element_block integer_block_type;
84 typedef typename string_block_type::value_type string_type;
85 typedef typename integer_block_type::value_type integer_type;
86 typedef size_t size_type;
93 typename traits_type::string_element_block,
typename traits_type::integer_element_block>;
99 typedef typename store_type::position_type position_type;
100 typedef typename store_type::const_position_type const_position_type;
113 size_pair_type(size_type _row, size_type _column) : row(_row), column(_column)
120 size_type* ptrs[2] = {&row, &column};
121 size_type** p = ptrs;
123 for (size_type v : vs)
129 return row == r.row && column == r.column;
133 return !operator==(r);
149 template<
typename _Blk>
150 typename _Blk::const_iterator begin()
const;
152 template<
typename _Blk>
153 typename _Blk::const_iterator end()
const;
156 void assign(
const const_position_type& pos, size_type section_size);
159 static mtm::element_t to_mtm_type(mdds::mtv::element_t mtv_type)
163 case string_block_type::block_type:
164 return mdds::mtm::element_string;
165 case integer_block_type::block_type:
166 return mdds::mtm::element_integer;
167 case mdds::mtv::element_type_double:
168 case mdds::mtv::element_type_boolean:
169 case mdds::mtv::element_type_empty:
171 return static_cast<mtm::element_t
>(mtv_type);
173 throw type_error(
"multi_type_matrix: unknown element type.");
178 template<
typename FuncT>
182 walk_func(FuncT& func) : m_func(func)
185 void operator()(
const typename store_type::const_iterator::value_type& mtv_node)
187 element_block_node_type mtm_node;
188 mtm_node.type = to_mtm_type(mtv_node.type);
189 mtm_node.size = mtv_node.size;
190 mtm_node.data = mtv_node.data;
239 template<
typename _T>
254 template<
typename _T>
283 position_type
position(size_type row, size_type col);
298 position_type
position(
const position_type& pos_hint, size_type row, size_type col);
310 const_position_type
position(size_type row, size_type col)
const;
324 const_position_type
position(
const const_position_type& pos_hint, size_type row, size_type col)
const;
362 mtm::element_t
get_type(
const const_position_type& pos)
const;
370 mtm::element_t
get_type(size_type row, size_type col)
const;
456 const string_type&
get_string(size_type row, size_type col)
const;
466 const string_type&
get_string(
const const_position_type& pos)
const;
478 template<
typename _T>
479 _T
get(size_type row, size_type col)
const;
500 void set_empty(size_type row, size_type col, size_type length);
532 void set(size_type row, size_type col,
double val);
542 position_type
set(
const position_type& pos,
double val);
551 void set(size_type row, size_type col,
bool val);
561 position_type
set(
const position_type& pos,
bool val);
570 void set(size_type row, size_type col,
const string_type& str);
580 position_type
set(
const position_type& pos,
const string_type& str);
589 void set(size_type row, size_type col, integer_type val);
599 position_type
set(
const position_type& pos, integer_type val);
617 template<
typename _T>
618 void set(size_type row, size_type col,
const _T& it_begin,
const _T& it_end);
634 template<
typename _T>
635 position_type
set(
const position_type& pos,
const _T& it_begin,
const _T& it_end);
648 template<
typename _T>
649 void set_column(size_type col,
const _T& it_begin,
const _T& it_end);
689 template<
typename _T>
690 void copy(size_type rows, size_type cols,
const _T& it_begin,
const _T& it_end);
702 void resize(size_type rows, size_type cols);
713 template<
typename _T>
714 void resize(size_type rows, size_type cols,
const _T& value);
750 template<
typename FuncT>
769 template<
typename FuncT>
782 template<
typename FuncT>
803 template<
typename FuncT>
807#ifdef MDDS_MULTI_TYPE_MATRIX_DEBUG
810 m_store.dump_blocks(std::cout);
825 inline size_type get_pos(size_type row, size_type col)
const
827 return m_size.row * col + row;
830 inline size_type get_pos(
const const_position_type& pos)
const
832 return pos.first->position + pos.second;
837 size_pair_type m_size;
842#include "multi_type_matrix_def.inl"
Definition: global.hpp:101
Definition: types.hpp:160
Definition: soa/main.hpp:73
Definition: multi_type_matrix.hpp:77
FuncT walk(FuncT func, const size_pair_type &start, const size_pair_type &end) const
void set(size_type row, size_type col, double val)
integer_type get_integer(size_type row, size_type col) const
void set_column_empty(size_type col)
void set_empty(size_type row, size_type col, size_type length)
void set(size_type row, size_type col, const _T &it_begin, const _T &it_end)
position_type set(const position_type &pos, bool val)
void copy(const multi_type_matrix &src)
multi_type_matrix(const multi_type_matrix &r)
FuncT walk(FuncT func) const
integer_type get_integer(const const_position_type &pos) const
const_position_type end_position() const
position_type end_position()
size_pair_type matrix_position(const const_position_type &pos) const
void set_empty(size_type row, size_type col)
void swap(multi_type_matrix &r)
static const_position_type next_position(const const_position_type &pos)
position_type set(const position_type &pos, integer_type val)
multi_type_matrix(size_type rows, size_type cols, const _T &value)
multi_type_matrix(size_type rows, size_type cols)
void resize(size_type rows, size_type cols)
mtm::element_t get_type(const const_position_type &pos) const
const_position_type position(size_type row, size_type col) const
bool get_boolean(const const_position_type &pos) const
position_type position(const position_type &pos_hint, size_type row, size_type col)
void set(size_type row, size_type col, integer_type val)
position_type set(const position_type &pos, const _T &it_begin, const _T &it_end)
multi_type_matrix & transpose()
void copy(size_type rows, size_type cols, const _T &it_begin, const _T &it_end)
position_type set(const position_type &pos, const string_type &str)
double get_numeric(const const_position_type &pos) const
position_type position(size_type row, size_type col)
void set(size_type row, size_type col, const string_type &str)
void resize(size_type rows, size_type cols, const _T &value)
const string_type & get_string(size_type row, size_type col) const
position_type set_empty(const position_type &pos)
const_position_type position(const const_position_type &pos_hint, size_type row, size_type col) const
void set_row_empty(size_type row)
position_type set(const position_type &pos, double val)
mtm::element_t get_type(size_type row, size_type col) const
multi_type_matrix(size_type rows, size_type cols, const _T &it_begin, const _T &it_end)
bool get_boolean(size_type row, size_type col) const
static position_type next_position(const position_type &pos)
FuncT walk(FuncT func, const multi_type_matrix &right) const
const string_type & get_string(const const_position_type &pos) const
double get_numeric(size_type row, size_type col) const
_T get(size_type row, size_type col) const
void set(size_type row, size_type col, bool val)
size_pair_type size() const
FuncT walk(FuncT func, const multi_type_matrix &right, const size_pair_type &start, const size_pair_type &end) const
void set_column(size_type col, const _T &it_begin, const _T &it_end)
Definition: global.hpp:115
Definition: multi_type_matrix.hpp:59
Definition: types.hpp:794
Definition: block_funcs.hpp:65
Definition: multi_type_matrix.hpp:138
Definition: multi_type_matrix.hpp:108