From 5dae8f8d10d506abc3c75a1f66c1dfe620c84fc1 Mon Sep 17 00:00:00 2001 From: HampusM Date: Tue, 15 Feb 2022 20:27:51 +0100 Subject: refactor: improve project design --- src/engine/matrix.tpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/engine/matrix.tpp') diff --git a/src/engine/matrix.tpp b/src/engine/matrix.tpp index bddf76a..d25de28 100644 --- a/src/engine/matrix.tpp +++ b/src/engine/matrix.tpp @@ -1,14 +1,15 @@ +#pragma once + #include "matrix.hpp" + #include template -Matrix::Matrix(unsigned int rows, unsigned int columns) +Matrix::Matrix(const Bounds &bounds) + : _rows(bounds.height()), _columns(bounds.width()) { - _rows = rows; - _columns = columns; - - _matrix.reserve(rows); - _matrix.assign(_matrix.capacity(), std::vector(columns)); + _matrix.reserve(bounds.height()); + _matrix.assign(_matrix.capacity(), std::vector(bounds.width())); }; template @@ -28,9 +29,9 @@ void Matrix::fill(Element element) template void Matrix::print() { - for (std::vector row : _matrix) + for (const std::vector &row : _matrix) { - for (Element element : row) + for (const Element &element : row) { std::cout << element; } -- cgit v1.2.3-18-g5258