aboutsummaryrefslogtreecommitdiff
path: root/src/engine/matrix_iterator.tpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/matrix_iterator.tpp')
-rw-r--r--src/engine/matrix_iterator.tpp112
1 files changed, 112 insertions, 0 deletions
diff --git a/src/engine/matrix_iterator.tpp b/src/engine/matrix_iterator.tpp
new file mode 100644
index 0000000..52952c9
--- /dev/null
+++ b/src/engine/matrix_iterator.tpp
@@ -0,0 +1,112 @@
+#pragma once
+
+#include "matrix_iterator.hpp"
+
+// Matrix row iterator
+
+template <typename Element>
+MatrixRowIterator<Element>::MatrixRowIterator(ColumnPtr column_ptr) noexcept
+ : _column_ptr(column_ptr)
+{
+}
+
+template <typename Element>
+MatrixRowIterator<Element> &MatrixRowIterator<Element>::operator++() noexcept
+{
+ ++_column_ptr;
+
+ return *this;
+}
+
+template <typename Element>
+MatrixRowIterator<Element> MatrixRowIterator<Element>::operator++(int) noexcept
+{
+ auto copy = *this;
+
+ ++(*this);
+
+ return copy;
+}
+
+template <typename Element>
+Element &MatrixRowIterator<Element>::operator*() const noexcept
+{
+ return *_column_ptr;
+}
+
+template <typename Element>
+bool MatrixRowIterator<Element>::operator==(const MatrixRowIterator &rhs) const noexcept
+{
+ return _column_ptr == rhs._column_ptr;
+}
+
+template <typename Element>
+bool MatrixRowIterator<Element>::operator!=(const MatrixRowIterator &rhs) const noexcept
+{
+ return _column_ptr != rhs._column_ptr;
+}
+
+// Matrix row
+
+template <typename Element>
+MatrixRow<Element>::MatrixRow(RowPtr row_ptr, const uint32_t &column_cnt) noexcept
+ : _row_ptr(row_ptr), _column_cnt(column_cnt)
+{
+}
+
+template <typename Element>
+MatrixRowIterator<Element> MatrixRow<Element>::begin() const noexcept
+{
+ return MatrixRowIterator<Element>(_row_ptr);
+}
+
+template <typename Element>
+MatrixRowIterator<Element> MatrixRow<Element>::end() const noexcept
+{
+ return MatrixRowIterator<Element>(_row_ptr + _column_cnt);
+}
+
+// Matrix iterator
+
+template <typename Element>
+MatrixIterator<Element>::MatrixIterator(RowPtr row_ptr,
+ const uint32_t &column_cnt) noexcept
+ : _row_ptr(row_ptr), _column_cnt(column_cnt)
+{
+}
+
+template <typename Element>
+MatrixIterator<Element> &MatrixIterator<Element>::operator++() noexcept
+{
+ ++_row_ptr;
+
+ return *this;
+}
+
+template <typename Element>
+MatrixIterator<Element> MatrixIterator<Element>::operator++(int) noexcept
+{
+ auto copy = *this;
+
+ ++(*this);
+
+ return copy;
+}
+
+template <typename Element>
+MatrixRow<Element> MatrixIterator<Element>::operator*() const noexcept
+{
+ return MatrixRow(*_row_ptr, _column_cnt);
+}
+
+template <typename Element>
+bool MatrixIterator<Element>::operator==(const MatrixIterator &rhs) const noexcept
+{
+ return _row_ptr == rhs._row_ptr;
+}
+
+template <typename Element>
+bool MatrixIterator<Element>::operator!=(const MatrixIterator &rhs) const noexcept
+{
+ return _row_ptr != rhs._row_ptr;
+}