aboutsummaryrefslogtreecommitdiff
path: root/src/engine/matrix_iterator.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/matrix_iterator.hpp')
-rw-r--r--src/engine/matrix_iterator.hpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/engine/matrix_iterator.hpp b/src/engine/matrix_iterator.hpp
new file mode 100644
index 0000000..5d35052
--- /dev/null
+++ b/src/engine/matrix_iterator.hpp
@@ -0,0 +1,65 @@
+#pragma once
+
+#include <gsl/pointers>
+
+template <typename Element>
+class MatrixRowIterator
+{
+public:
+ using ColumnPtr = gsl::owner<Element *>;
+
+ explicit MatrixRowIterator(ColumnPtr column_ptr) noexcept;
+
+ MatrixRowIterator &operator++() noexcept;
+ MatrixRowIterator operator++(int) noexcept;
+
+ Element &operator*() const noexcept;
+
+ bool operator==(const MatrixRowIterator &rhs) const noexcept;
+ bool operator!=(const MatrixRowIterator &rhs) const noexcept;
+
+private:
+ ColumnPtr _column_ptr;
+};
+
+template <typename Element>
+class MatrixRow
+{
+public:
+ using RowPtr = gsl::owner<Element *>;
+
+ explicit MatrixRow(RowPtr row_ptr, const uint32_t &column_cnt) noexcept;
+
+ [[nodiscard]] MatrixRowIterator<Element> begin() const noexcept;
+
+ [[nodiscard]] MatrixRowIterator<Element> end() const noexcept;
+
+private:
+ RowPtr _row_ptr;
+
+ const uint32_t &_column_cnt;
+};
+
+template <typename Element>
+class MatrixIterator
+{
+public:
+ using RowPtr = gsl::owner<Element **>;
+
+ explicit MatrixIterator(RowPtr row_ptr, const uint32_t &column_cnt) noexcept;
+
+ MatrixIterator &operator++() noexcept;
+ MatrixIterator operator++(int) noexcept;
+
+ MatrixRow<Element> operator*() const noexcept;
+
+ bool operator==(const MatrixIterator &rhs) const noexcept;
+ bool operator!=(const MatrixIterator &rhs) const noexcept;
+
+private:
+ RowPtr _row_ptr;
+
+ const uint32_t &_column_cnt;
+};
+
+#include "matrix_iterator.tpp"