aboutsummaryrefslogtreecommitdiff
path: root/src/engine/graphics/string_matrix.cpp
blob: e259e96b835d8b6705341dc748f1ee532a88e16f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "string_matrix.hpp"

StringMatrix::StringMatrix(const IBounds &bounds)
	: _rows(bounds.height()), _columns(bounds.width())
{
	_matrix.reserve(bounds.height());
	_matrix.assign(_matrix.capacity(), std::vector<std::string_view>(bounds.width()));
};

void StringMatrix::fill(std::string_view element)
{
	for (unsigned int row = 0U; row < _matrix.capacity(); row++)
	{
		std::vector<std::string_view> row_vector = _matrix[row];

		for (unsigned int column = 0U; column < row_vector.capacity(); column++)
		{
			_matrix[row][column] = element;
		}
	}
}

std::string_view StringMatrix::get(const IVector2 &pos) const
{
	return _matrix[pos.y()][pos.x()];
}

void StringMatrix::set(const IVector2 &pos, std::string_view element)
{
	_matrix[pos.y()][pos.x()] = element;
}

unsigned int StringMatrix::rows() const
{
	return _rows;
}

unsigned int StringMatrix::columns() const
{
	return _columns;
}