aboutsummaryrefslogtreecommitdiff
path: root/src/engine/matrix_iterator_impl.hpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-06-02 20:50:28 +0200
committerHampusM <hampus@hampusmat.com>2022-06-13 17:57:00 +0200
commit7578eb6f79afbb421298088ee53da620eb04037f (patch)
tree6784011258b6967e75cf8478356c651c1c45938b /src/engine/matrix_iterator_impl.hpp
parentea5cd08dd67f9bc4351ecebdda9e310a8072ae32 (diff)
refactor: rename .tpp files to end with _impl.hpp
Diffstat (limited to 'src/engine/matrix_iterator_impl.hpp')
-rw-r--r--src/engine/matrix_iterator_impl.hpp115
1 files changed, 115 insertions, 0 deletions
diff --git a/src/engine/matrix_iterator_impl.hpp b/src/engine/matrix_iterator_impl.hpp
new file mode 100644
index 0000000..4b2c785
--- /dev/null
+++ b/src/engine/matrix_iterator_impl.hpp
@@ -0,0 +1,115 @@
+#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>
+auto MatrixRowIterator<Element>::operator++() noexcept -> MatrixRowIterator<Element> &
+{
+ ++_column_ptr;
+
+ return *this;
+}
+
+template <typename Element>
+auto MatrixRowIterator<Element>::operator++(int) noexcept -> MatrixRowIterator<Element>
+{
+ auto copy = *this;
+
+ ++(*this);
+
+ return copy;
+}
+
+template <typename Element>
+auto MatrixRowIterator<Element>::operator*() const noexcept -> Element &
+{
+ return *_column_ptr;
+}
+
+template <typename Element>
+auto MatrixRowIterator<Element>::operator==(const MatrixRowIterator &rhs) const noexcept
+ -> bool
+{
+ return _column_ptr == rhs._column_ptr;
+}
+
+template <typename Element>
+auto MatrixRowIterator<Element>::operator!=(const MatrixRowIterator &rhs) const noexcept
+ -> bool
+{
+ 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>
+auto MatrixRow<Element>::begin() const noexcept -> MatrixRowIterator<Element>
+{
+ return MatrixRowIterator<Element>(_row_ptr);
+}
+
+template <typename Element>
+auto MatrixRow<Element>::end() const noexcept -> MatrixRowIterator<Element>
+{
+ 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>
+auto MatrixIterator<Element>::operator++() noexcept -> MatrixIterator<Element> &
+{
+ ++_row_ptr;
+
+ return *this;
+}
+
+template <typename Element>
+auto MatrixIterator<Element>::operator++(int) noexcept -> MatrixIterator<Element>
+{
+ auto copy = *this;
+
+ ++(*this);
+
+ return copy;
+}
+
+template <typename Element>
+auto MatrixIterator<Element>::operator*() const noexcept -> MatrixRow<Element>
+{
+ return MatrixRow(*_row_ptr, _column_cnt);
+}
+
+template <typename Element>
+auto MatrixIterator<Element>::operator==(const MatrixIterator &rhs) const noexcept -> bool
+{
+ return _row_ptr == rhs._row_ptr;
+}
+
+template <typename Element>
+auto MatrixIterator<Element>::operator!=(const MatrixIterator &rhs) const noexcept -> bool
+{
+ return _row_ptr != rhs._row_ptr;
+}