From 531dc783d8edd4f846f4d74948a66f87ff41b083 Mon Sep 17 00:00:00 2001 From: Relintai Date: Thu, 21 Apr 2022 16:36:33 +0200 Subject: [PATCH] std::size_t to uint32_t for the wfc module. --- modules/wfc/array_2d.h | 28 ++++++++++++++-------------- modules/wfc/array_3d.h | 16 ++++++++-------- modules/wfc/propagator.h | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/modules/wfc/array_2d.h b/modules/wfc/array_2d.h index 749c2644a..1090db721 100644 --- a/modules/wfc/array_2d.h +++ b/modules/wfc/array_2d.h @@ -7,38 +7,38 @@ template class Array2D { public: - std::size_t height; - std::size_t width; + uint32_t height; + uint32_t width; Vector data; - Array2D(std::size_t p_height, std::size_t p_width) { + Array2D(uint32_t p_height, uint32_t p_width) { height = p_height; width = p_width; data.resize(width * height); } - Array2D(std::size_t p_height, std::size_t p_width, T p_value) { + Array2D(uint32_t p_height, uint32_t p_width, T p_value) { height = p_height; width = p_width; data.resize(width * height); data.fill(p_value); } - const T &get(std::size_t i, std::size_t j) const { + const T &get(uint32_t i, uint32_t j) const { assert(i < height && j < width); return data[j + i * width]; } - T &get(std::size_t i, std::size_t j) { + T &get(uint32_t i, uint32_t j) { assert(i < height && j < width); return data.write[j + i * width]; } Array2D reflected() const { Array2D result = Array2D(width, height); - for (std::size_t y = 0; y < height; y++) { - for (std::size_t x = 0; x < width; x++) { + for (uint32_t y = 0; y < height; y++) { + for (uint32_t x = 0; x < width; x++) { result.get(y, x) = get(y, width - 1 - x); } } @@ -47,18 +47,18 @@ public: Array2D rotated() const { Array2D result = Array2D(width, height); - for (std::size_t y = 0; y < width; y++) { - for (std::size_t x = 0; x < height; x++) { + for (uint32_t y = 0; y < width; y++) { + for (uint32_t x = 0; x < height; x++) { result.get(y, x) = get(x, width - 1 - y); } } return result; } - Array2D get_sub_array(std::size_t y, std::size_t x, std::size_t sub_width, std::size_t sub_height) const { + Array2D get_sub_array(uint32_t y, uint32_t x, uint32_t sub_width, uint32_t sub_height) const { Array2D sub_array_2d = Array2D(sub_width, sub_height); - for (std::size_t ki = 0; ki < sub_height; ki++) { - for (std::size_t kj = 0; kj < sub_width; kj++) { + for (uint32_t ki = 0; ki < sub_height; ki++) { + for (uint32_t kj = 0; kj < sub_width; kj++) { sub_array_2d.get(ki, kj) = get((y + ki) % height, (x + kj) % width); } } @@ -70,7 +70,7 @@ public: return false; } - for (std::size_t i = 0; i < data.size(); i++) { + for (uint32_t i = 0; i < data.size(); i++) { if (a.data[i] != data[i]) { return false; } diff --git a/modules/wfc/array_3d.h b/modules/wfc/array_3d.h index c3bb8ff6b..eb0c526f6 100644 --- a/modules/wfc/array_3d.h +++ b/modules/wfc/array_3d.h @@ -7,20 +7,20 @@ template class Array3D { public: - std::size_t height; - std::size_t width; - std::size_t depth; + uint32_t height; + uint32_t width; + uint32_t depth; Vector data; - Array3D(std::size_t p_height, std::size_t p_width, std::size_t p_depth) { + Array3D(uint32_t p_height, uint32_t p_width, uint32_t p_depth) { height = p_height; width = p_width; depth = p_depth; data.resize(width * height * depth); } - Array3D(std::size_t p_height, std::size_t p_width, std::size_t p_depth, T value) { + Array3D(uint32_t p_height, uint32_t p_width, uint32_t p_depth, T value) { height = p_height; width = p_width; depth = p_depth; @@ -28,12 +28,12 @@ public: data.fill(value); } - const T &get(std::size_t i, std::size_t j, std::size_t k) const { + const T &get(uint32_t i, uint32_t j, uint32_t k) const { assert(i < height && j < width && k < depth); return data[i * width * depth + j * depth + k]; } - T &get(std::size_t i, std::size_t j, std::size_t k) { + T &get(uint32_t i, uint32_t j, uint32_t k) { return data.write[i * width * depth + j * depth + k]; } @@ -42,7 +42,7 @@ public: return false; } - for (std::size_t i = 0; i < data.size(); i++) { + for (uint32_t i = 0; i < data.size(); i++) { if (a.data[i] != data[i]) { return false; } diff --git a/modules/wfc/propagator.h b/modules/wfc/propagator.h index bde774066..5883a6bc8 100644 --- a/modules/wfc/propagator.h +++ b/modules/wfc/propagator.h @@ -14,7 +14,7 @@ public: using PropagatorState = Vector, 4>>; private: - const std::size_t patterns_size; + const uint32_t patterns_size; PropagatorState propagator_state;