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"
38 #include "multi_type_vector_trait.hpp"
49 element_empty = mdds::mtv::element_type_empty,
50 element_boolean = mdds::mtv::element_type_boolean,
51 element_string = mdds::mtv::element_type_string,
52 element_numeric = mdds::mtv::element_type_double,
53 element_integer = mdds::mtv::element_type_int32
78 template<
typename _MtxTrait>
81 typedef _MtxTrait matrix_trait;
84 typedef typename matrix_trait::string_element_block string_block_type;
85 typedef typename matrix_trait::integer_element_block integer_block_type;
87 typedef typename string_block_type::value_type string_type;
88 typedef typename integer_block_type::value_type integer_type;
89 typedef size_t size_type;
95 typedef typename store_type::position_type position_type;
96 typedef typename store_type::const_position_type const_position_type;
109 size_pair_type(size_type _row, size_type _column) : row(_row), column(_column)
116 size_type* ptrs[2] = {&row, &column};
117 size_type** p = ptrs;
119 for (size_type v : vs)
125 return row == r.row && column == r.column;
129 return !operator==(r);
145 template<
typename _Blk>
146 typename _Blk::const_iterator begin()
const;
148 template<
typename _Blk>
149 typename _Blk::const_iterator end()
const;
152 void assign(
const const_position_type& pos, size_type section_size);
155 static mtm::element_t to_mtm_type(mdds::mtv::element_t mtv_type)
159 case string_block_type::block_type:
160 return mdds::mtm::element_string;
161 case integer_block_type::block_type:
162 return mdds::mtm::element_integer;
163 case mdds::mtv::element_type_double:
164 case mdds::mtv::element_type_boolean:
165 case mdds::mtv::element_type_empty:
167 return static_cast<mtm::element_t
>(mtv_type);
169 throw type_error(
"multi_type_matrix: unknown element type.");
174 template<
typename _Func>
178 walk_func(_Func& func) : m_func(func)
181 void operator()(
const typename store_type::const_iterator::value_type& mtv_node)
183 element_block_node_type mtm_node;
184 mtm_node.type = to_mtm_type(mtv_node.type);
185 mtm_node.size = mtv_node.size;
186 mtm_node.data = mtv_node.data;
235 template<
typename _T>
250 template<
typename _T>
279 position_type
position(size_type row, size_type col);
294 position_type
position(
const position_type& pos_hint, size_type row, size_type col);
306 const_position_type
position(size_type row, size_type col)
const;
320 const_position_type
position(
const const_position_type& pos_hint, size_type row, size_type col)
const;
358 mtm::element_t
get_type(
const const_position_type& pos)
const;
366 mtm::element_t
get_type(size_type row, size_type col)
const;
452 const string_type&
get_string(size_type row, size_type col)
const;
462 const string_type&
get_string(
const const_position_type& pos)
const;
474 template<
typename _T>
475 _T
get(size_type row, size_type col)
const;
496 void set_empty(size_type row, size_type col, size_type length);
528 void set(size_type row, size_type col,
double val);
538 position_type
set(
const position_type& pos,
double val);
547 void set(size_type row, size_type col,
bool val);
557 position_type
set(
const position_type& pos,
bool val);
566 void set(size_type row, size_type col,
const string_type& str);
576 position_type
set(
const position_type& pos,
const string_type& str);
585 void set(size_type row, size_type col, integer_type val);
595 position_type
set(
const position_type& pos, integer_type val);
613 template<
typename _T>
614 void set(size_type row, size_type col,
const _T& it_begin,
const _T& it_end);
630 template<
typename _T>
631 position_type
set(
const position_type& pos,
const _T& it_begin,
const _T& it_end);
644 template<
typename _T>
645 void set_column(size_type col,
const _T& it_begin,
const _T& it_end);
685 template<
typename _T>
686 void copy(size_type rows, size_type cols,
const _T& it_begin,
const _T& it_end);
698 void resize(size_type rows, size_type cols);
709 template<
typename _T>
710 void resize(size_type rows, size_type cols,
const _T& value);
746 template<
typename _Func>
765 template<
typename _Func>
778 template<
typename _Func>
799 template<
typename _Func>
803 #ifdef MDDS_MULTI_TYPE_MATRIX_DEBUG
806 m_store.dump_blocks(std::cout);
821 inline size_type get_pos(size_type row, size_type col)
const
823 return m_size.row * col + row;
826 inline size_type get_pos(
const const_position_type& pos)
const
828 return pos.first->position + pos.second;
833 size_pair_type m_size;
838 #include "multi_type_matrix_def.inl"
Definition: global.hpp:101
Definition: types.hpp:174
Definition: soa/main.hpp:73
Definition: multi_type_matrix.hpp:80
integer_type get_integer(const const_position_type &pos) const
void set(size_type row, size_type col, const string_type &str)
void set_row_empty(size_type row)
multi_type_matrix & transpose()
void swap(multi_type_matrix &r)
multi_type_matrix(size_type rows, size_type cols, const _T &value)
position_type set(const position_type &pos, integer_type val)
void set_empty(size_type row, size_type col)
position_type set(const position_type &pos, bool val)
void copy(const multi_type_matrix &src)
void set_empty(size_type row, size_type col, size_type length)
bool get_boolean(const const_position_type &pos) const
const string_type & get_string(const const_position_type &pos) const
void resize(size_type rows, size_type cols)
_Func walk(_Func func) const
position_type position(size_type row, size_type col)
void resize(size_type rows, size_type cols, const _T &value)
void set(size_type row, size_type col, bool val)
mtm::element_t get_type(const const_position_type &pos) const
void set(size_type row, size_type col, const _T &it_begin, const _T &it_end)
static const_position_type next_position(const const_position_type &pos)
bool get_boolean(size_type row, size_type col) const
position_type set(const position_type &pos, const string_type &str)
double get_numeric(size_type row, size_type col) const
mtm::element_t get_type(size_type row, size_type col) const
void copy(size_type rows, size_type cols, const _T &it_begin, const _T &it_end)
_T get(size_type row, size_type col) const
size_pair_type size() const
double get_numeric(const const_position_type &pos) const
position_type set(const position_type &pos, const _T &it_begin, const _T &it_end)
_Func walk(_Func func, const size_pair_type &start, const size_pair_type &end) const
void set(size_type row, size_type col, integer_type val)
multi_type_matrix(const multi_type_matrix &r)
void set_column(size_type col, const _T &it_begin, const _T &it_end)
void set(size_type row, size_type col, double val)
multi_type_matrix(size_type rows, size_type cols, const _T &it_begin, const _T &it_end)
size_pair_type matrix_position(const const_position_type &pos) const
const_position_type end_position() const
position_type position(const position_type &pos_hint, size_type row, size_type col)
position_type set_empty(const position_type &pos)
const string_type & get_string(size_type row, size_type col) const
void set_column_empty(size_type col)
static position_type next_position(const position_type &pos)
const_position_type position(const const_position_type &pos_hint, size_type row, size_type col) const
integer_type get_integer(size_type row, size_type col) const
_Func walk(_Func func, const multi_type_matrix &right, const size_pair_type &start, const size_pair_type &end) const
position_type end_position()
const_position_type position(size_type row, size_type col) const
multi_type_matrix(size_type rows, size_type cols)
position_type set(const position_type &pos, double val)
_Func walk(_Func func, const multi_type_matrix &right) const
Definition: global.hpp:115
Definition: multi_type_matrix.hpp:60
Definition: types.hpp:616
Definition: trait.hpp:746
Definition: multi_type_matrix.hpp:134
Definition: multi_type_matrix.hpp:104