From 7c45fa2fad5d69b822824ee56294fdd2b9a674f7 Mon Sep 17 00:00:00 2001 From: kai Date: Sun, 15 Jun 2025 13:55:27 +0200 Subject: [PATCH] add super_grid --- lab11/game_of_life/super_grid.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lab11/game_of_life/super_grid.h diff --git a/lab11/game_of_life/super_grid.h b/lab11/game_of_life/super_grid.h new file mode 100644 index 0000000..80ef7ba --- /dev/null +++ b/lab11/game_of_life/super_grid.h @@ -0,0 +1,29 @@ +#ifndef SUPER_GRID_H +#define SUPER_GRID_H + +#include "matrix.h" + +class SuperGrid { +public: + static SuperGrid zeros(int rows, int cols); + + int rows() const; + int cols() const; + double &operator()(int i, int j); + +private: + Matrix grid_; +}; + +inline SuperGrid SuperGrid::zeros(int rows, int cols) + : grid_(Matrix::zeros(rows + 2, cols + 2)), {} + +inline double &SuperGrid::operator()(int i, int j) { + return this->grid_(i + 1, j + 1); +} + +inline int SuperGrid::rows() const { return this->grid_.rows() - 2; } + +inline int SuperGrid::cols() const { return this->grid_.cols() - 2; } + +#endif // SUPER_GRID_H