1#ifndef TBQ_CONTAINER_ARRAY2D_H
2#define TBQ_CONTAINER_ARRAY2D_H
27 explicit Array2D(
size_t nbRows,
size_t nbCols);
37 void resize(
size_t nbRows,
size_t nbCols);
39 void insert(
size_t row,
size_t col,
const T &value);
43 const T&
operator()(
size_t row,
size_t col)
const;
48 return left.m_rows == right.m_rows
49 && left.m_cols == right.m_cols
50 && left.m_data == right.m_data;
55 return !(left == right);
81 resize(nbRows, nbCols);
89 : m_rows(0), m_cols(0)
136 return m_rows * m_cols;
151 return QSize(m_cols, m_rows);
191 m_data.resize(m_rows * m_cols);
210 (*this)(row, col) = value;
229 return m_data[row * m_cols + col];
248 return m_data[row * m_cols + col];
Use to manage a 2-dimensional array.
Definition array2d.h:24
void insert(size_t row, size_t col, const T &value)
Use to insert a value at specified indexes.
Definition array2d.h:208
Array2D()
Construct an empty 2D array.
Definition array2d.h:88
QSize getSize() const
Get matrix size.
Definition array2d.h:149
void resize(size_t nbRows, size_t nbCols)
Resize array to specified size.
Definition array2d.h:187
size_t getRows() const
Get number of rows.
Definition array2d.h:104
T & operator()(size_t row, size_t col)
Get modifiable reference to an element.
Definition array2d.h:227
size_t getNbElements() const
Get number of elements of 2D array.
Definition array2d.h:134
size_t getCols() const
Get number of columns.
Definition array2d.h:119
void clear()
Clear content of 2D array.
Definition array2d.h:167
Namespace used for ToolBoxQt library.
Definition array2d.h:12