A bit of late night work designing the little iterators.

This commit is contained in:
Zed A. Shaw 2024-12-14 11:00:52 -05:00
parent da0b941dfd
commit 8e470df554
11 changed files with 115 additions and 235 deletions

View file

@ -2,16 +2,43 @@
#include <vector>
#include <string>
typedef std::vector<int> MatrixRow;
typedef std::vector<MatrixRow> Matrix;
namespace matrix {
/*
* Just a quick thing to reset a matrix to a value.
*/
inline void matrix_assign(Matrix &out, int new_value) {
for(auto &row : out) {
row.assign(row.size(), new_value);
typedef std::vector<int> Row;
typedef std::vector<Row> Matrix;
struct each_cell {
size_t x = ~0;
size_t y = ~0;
size_t width = 0;
size_t height = 0;
int cell = 0;
each_cell(Matrix &mat);
bool next();
};
struct each_row {
Matrix &$mat;
size_t x = ~0;
size_t y = ~0;
size_t width = 0;
size_t height = 0;
int cell = 0;
bool row = false;
each_row(Matrix &mat);
bool next();
};
/*
* Just a quick thing to reset a matrix to a value.
*/
inline void assign(Matrix &out, int new_value) {
for(auto &row : out) {
row.assign(row.size(), new_value);
}
}
}
void matrix_dump(const std::string &msg, Matrix &map, int show_x=-1, int show_y=-1);
void dump(const std::string &msg, Matrix &map, int show_x=-1, int show_y=-1);
}