diff options
author | Adrian Kummerlaender | 2017-03-26 15:38:58 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2017-03-26 15:38:58 +0200 |
commit | 7e3ea6b0080b2c9127964a096a27369d8cc59c67 (patch) | |
tree | 5f69a365fb9d5ebd9f1646ceadc7da75364b083c /src/util/torus_array.h | |
parent | 1266502d8f0e72c135198278fcccf75b519cee44 (diff) | |
download | termlife-7e3ea6b0080b2c9127964a096a27369d8cc59c67.tar termlife-7e3ea6b0080b2c9127964a096a27369d8cc59c67.tar.gz termlife-7e3ea6b0080b2c9127964a096a27369d8cc59c67.tar.bz2 termlife-7e3ea6b0080b2c9127964a096a27369d8cc59c67.tar.lz termlife-7e3ea6b0080b2c9127964a096a27369d8cc59c67.tar.xz termlife-7e3ea6b0080b2c9127964a096a27369d8cc59c67.tar.zst termlife-7e3ea6b0080b2c9127964a096a27369d8cc59c67.zip |
Rename `TorusArray` to `TorusMatrix` to better fit the represented structure
Diffstat (limited to 'src/util/torus_array.h')
-rw-r--r-- | src/util/torus_array.h | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/src/util/torus_array.h b/src/util/torus_array.h deleted file mode 100644 index bef0c9f..0000000 --- a/src/util/torus_array.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef LIFE_SRC_UTIL_TORUS_ARRAY_ -#define LIFE_SRC_UTIL_TORUS_ARRAY_ - -#include <array> -#include <cstdint> - -namespace life { -namespace util { - -template< - typename TYPE, - std::size_t WIDTH, - std::size_t HEIGHT -> -class TorusArray { - static std::size_t toMatrixColumn(const std::ptrdiff_t x) { - if ( x >= 0 ) { - return x % WIDTH; - } else { - return WIDTH - ( std::abs(x) % WIDTH ); - } - } - - static std::size_t toMatrixRow(const std::ptrdiff_t y) { - if ( y >= 0 ) { - return y % HEIGHT; - } else { - return HEIGHT - ( std::abs(y) % HEIGHT ); - } - } - - public: - static const std::size_t width = WIDTH; - static const std::size_t height = HEIGHT; - - TYPE get(const std::ptrdiff_t x, const std::ptrdiff_t y) const { - return this->matrix_[toMatrixRow(y)][toMatrixColumn(x)]; - } - - void set(const std::ptrdiff_t x, const std::ptrdiff_t y, TYPE&& value) { - this->matrix_[toMatrixRow(y)][toMatrixColumn(x)] = value; - } - - private: - std::array<std::array<TYPE, WIDTH>, HEIGHT> matrix_; - -}; - -} -} - -#endif // LIFE_SRC_UTIL_TORUS_ARRAY_ |