aboutsummaryrefslogtreecommitdiff
path: root/src/engine/matrix.tpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-02-15 20:27:51 +0100
committerHampusM <hampus@hampusmat.com>2022-02-15 20:27:51 +0100
commit5dae8f8d10d506abc3c75a1f66c1dfe620c84fc1 (patch)
tree2bfb6efef0535a35bab1da811a5f69cb5203dff9 /src/engine/matrix.tpp
parent9147551cd21d565f9503e3ebbcd2121e284d88d5 (diff)
refactor: improve project design
Diffstat (limited to 'src/engine/matrix.tpp')
-rw-r--r--src/engine/matrix.tpp17
1 files changed, 9 insertions, 8 deletions
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 <iostream>
template <typename Element>
-Matrix<Element>::Matrix(unsigned int rows, unsigned int columns)
+Matrix<Element>::Matrix(const Bounds &bounds)
+ : _rows(bounds.height()), _columns(bounds.width())
{
- _rows = rows;
- _columns = columns;
-
- _matrix.reserve(rows);
- _matrix.assign(_matrix.capacity(), std::vector<Element>(columns));
+ _matrix.reserve(bounds.height());
+ _matrix.assign(_matrix.capacity(), std::vector<Element>(bounds.width()));
};
template <typename Element>
@@ -28,9 +29,9 @@ void Matrix<Element>::fill(Element element)
template <typename Element>
void Matrix<Element>::print()
{
- for (std::vector<Element> row : _matrix)
+ for (const std::vector<Element> &row : _matrix)
{
- for (Element element : row)
+ for (const Element &element : row)
{
std::cout << element;
}