1#ifndef TBQ_CONTAINER_ARRAY2D_H
2#define TBQ_CONTAINER_ARRAY2D_H
4#include "toolboxqt/toolboxqt_global.h"
28 explicit Array2D(
size_t nbRows,
size_t nbCols);
31 size_t getRows()
const;
32 size_t getCols()
const;
33 size_t getSize()
const;
37 void resize(
size_t nbRows,
size_t nbCols);
39 void insert(
size_t row,
size_t col,
const T &value);
42 T& operator()(
size_t row,
size_t col);
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(m_rows, m_cols);
89 : m_rows(0), m_cols(0)
134 return m_rows * m_cols;
174 m_data.resize(m_rows * m_cols);
193 (*this)(row, col) = value;
212 return m_data[row * m_cols + col];
231 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:191
Array2D()
Construct an empty 2D array.
Definition: array2d.h:88
size_t getSize() const
Get total size of 2D array (a.k.a number of elements)
Definition: array2d.h:132
void resize(size_t nbRows, size_t nbCols)
Resize array to specified size.
Definition: array2d.h:170
size_t getRows() const
Get number of rows.
Definition: array2d.h:103
T & operator()(size_t row, size_t col)
Get modifiable reference to an element.
Definition: array2d.h:210
size_t getCols() const
Get number of columns.
Definition: array2d.h:117
void clear()
Clear content of 2D array.
Definition: array2d.h:150