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_numeric,
53 element_integer = mdds::mtv::element_type_int
75 template<
typename _MtxTrait>
78 typedef _MtxTrait matrix_trait;
80 typedef typename matrix_trait::string_element_block string_block_type;
81 typedef typename matrix_trait::integer_element_block integer_block_type;
83 typedef typename string_block_type::value_type string_type;
84 typedef typename integer_block_type::value_type integer_type;
85 typedef size_t size_type;
91 typedef typename store_type::position_type position_type;
92 typedef typename store_type::const_position_type const_position_type;
104 size_pair_type(size_type _row, size_type _column) : row(_row), column(_column) {}
110 size_type* ptrs[2] = { &row, &column };
111 size_type** p = ptrs;
113 for (size_type v : vs)
117 bool operator== (
const size_pair_type& r)
const {
return row == r.row && column == r.column; }
118 bool operator!= (
const size_pair_type& r)
const {
return !operator== (r); }
128 const element_block_type* data;
133 template<
typename _Blk>
134 typename _Blk::const_iterator begin()
const;
136 template<
typename _Blk>
137 typename _Blk::const_iterator end()
const;
140 void assign(
const const_position_type& pos, size_type section_size);
143 static mtm::element_t to_mtm_type(mdds::mtv::element_t mtv_type)
147 case string_block_type::block_type:
148 return mdds::mtm::element_string;
149 case integer_block_type::block_type:
150 return mdds::mtm::element_integer;
151 case mdds::mtv::element_type_numeric:
152 case mdds::mtv::element_type_boolean:
153 case mdds::mtv::element_type_empty:
155 return static_cast<mtm::element_t
>(mtv_type);
157 throw type_error(
"multi_type_matrix: unknown element type.");
162 template<
typename _Func>
166 walk_func(_Func& func) : m_func(func) {}
171 mtm_node.type = to_mtm_type(mtv_node.type);
172 mtm_node.size = mtv_node.size;
173 mtm_node.data = mtv_node.data;
188 static position_type next_position(
const position_type& pos);
199 static const_position_type next_position(
const const_position_type& pos);
222 template<
typename _T>
235 template<
typename _T>
236 multi_type_matrix(size_type rows, size_type cols,
const _T& it_begin,
const _T& it_end);
264 position_type position(size_type row, size_type col);
279 position_type position(
const position_type& pos_hint, size_type row, size_type col);
291 const_position_type position(size_type row, size_type col)
const;
305 const_position_type position(
const const_position_type& pos_hint, size_type row, size_type col)
const;
315 size_pair_type matrix_position(
const const_position_type& pos)
const;
324 position_type end_position();
333 const_position_type end_position()
const;
343 mtm::element_t get_type(
const const_position_type& pos)
const;
351 mtm::element_t get_type(size_type row, size_type col)
const;
364 double get_numeric(size_type row, size_type col)
const;
376 double get_numeric(
const const_position_type& pos)
const;
389 integer_type get_integer(size_type row, size_type col)
const;
401 integer_type get_integer(
const const_position_type& pos)
const;
414 bool get_boolean(size_type row, size_type col)
const;
426 bool get_boolean(
const const_position_type& pos)
const;
437 const string_type& get_string(size_type row, size_type col)
const;
447 const string_type& get_string(
const const_position_type& pos)
const;
459 template<
typename _T>
460 _T
get(size_type row, size_type col)
const;
468 void set_empty(size_type row, size_type col);
477 void set_empty(size_type row, size_type col, size_type length);
486 position_type set_empty(
const position_type& pos);
493 void set_column_empty(size_type col);
500 void set_row_empty(size_type row);
509 void set(size_type row, size_type col,
double val);
519 position_type
set(
const position_type& pos,
double val);
528 void set(size_type row, size_type col,
bool val);
538 position_type
set(
const position_type& pos,
bool val);
547 void set(size_type row, size_type col,
const string_type& str);
557 position_type
set(
const position_type& pos,
const string_type& str);
566 void set(size_type row, size_type col, integer_type val);
576 position_type
set(
const position_type& pos, integer_type val);
594 template<
typename _T>
595 void set(size_type row, size_type col,
const _T& it_begin,
const _T& it_end);
611 template<
typename _T>
612 position_type
set(
const position_type& pos,
const _T& it_begin,
const _T& it_end);
625 template<
typename _T>
626 void set_column(size_type col,
const _T& it_begin,
const _T& it_end);
666 template<
typename _T>
667 void copy(size_type rows, size_type cols,
const _T& it_begin,
const _T& it_end);
679 void resize(size_type rows, size_type cols);
690 template<
typename _T>
691 void resize(size_type rows, size_type cols,
const _T& value);
705 bool numeric()
const;
727 template<
typename _Func>
728 _Func walk(_Func func)
const;
746 template<
typename _Func>
759 template<
typename _Func>
780 template<
typename _Func>
785 #ifdef MDDS_MULTI_TYPE_MATRIX_DEBUG 788 m_store.dump_blocks(std::cout);
804 inline size_type get_pos(size_type row, size_type col)
const 806 return m_size.row * col + row;
809 inline size_type get_pos(
const const_position_type& pos)
const 811 return pos.first->position + pos.second;
821 #include "multi_type_matrix_def.inl" Definition: multi_type_vector_itr.hpp:44
Definition: multi_type_vector_trait.hpp:700
Definition: multi_type_vector_types.hpp:87
Definition: global.hpp:84
Definition: global.hpp:72
Definition: multi_type_matrix.hpp:99
Definition: multi_type_vector_types.hpp:513
Definition: multi_type_matrix.hpp:76
Definition: flat_segment_tree.hpp:46
Definition: multi_type_matrix.hpp:59
Definition: multi_type_matrix.hpp:121