From 7578eb6f79afbb421298088ee53da620eb04037f Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 2 Jun 2022 20:50:28 +0200 Subject: refactor: rename .tpp files to end with _impl.hpp --- src/engine/matrix_iterator_impl.hpp | 115 ++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 src/engine/matrix_iterator_impl.hpp (limited to 'src/engine/matrix_iterator_impl.hpp') 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 +MatrixRowIterator::MatrixRowIterator(ColumnPtr column_ptr) noexcept + : _column_ptr(column_ptr) +{ +} + +template +auto MatrixRowIterator::operator++() noexcept -> MatrixRowIterator & +{ + ++_column_ptr; + + return *this; +} + +template +auto MatrixRowIterator::operator++(int) noexcept -> MatrixRowIterator +{ + auto copy = *this; + + ++(*this); + + return copy; +} + +template +auto MatrixRowIterator::operator*() const noexcept -> Element & +{ + return *_column_ptr; +} + +template +auto MatrixRowIterator::operator==(const MatrixRowIterator &rhs) const noexcept + -> bool +{ + return _column_ptr == rhs._column_ptr; +} + +template +auto MatrixRowIterator::operator!=(const MatrixRowIterator &rhs) const noexcept + -> bool +{ + return _column_ptr != rhs._column_ptr; +} + +// Matrix row + +template +MatrixRow::MatrixRow(RowPtr row_ptr, const uint32_t &column_cnt) noexcept + : _row_ptr(row_ptr), _column_cnt(column_cnt) +{ +} + +template +auto MatrixRow::begin() const noexcept -> MatrixRowIterator +{ + return MatrixRowIterator(_row_ptr); +} + +template +auto MatrixRow::end() const noexcept -> MatrixRowIterator +{ + return MatrixRowIterator(_row_ptr + _column_cnt); +} + +// Matrix iterator + +template +MatrixIterator::MatrixIterator( + RowPtr row_ptr, + const uint32_t &column_cnt) noexcept + : _row_ptr(row_ptr), _column_cnt(column_cnt) +{ +} + +template +auto MatrixIterator::operator++() noexcept -> MatrixIterator & +{ + ++_row_ptr; + + return *this; +} + +template +auto MatrixIterator::operator++(int) noexcept -> MatrixIterator +{ + auto copy = *this; + + ++(*this); + + return copy; +} + +template +auto MatrixIterator::operator*() const noexcept -> MatrixRow +{ + return MatrixRow(*_row_ptr, _column_cnt); +} + +template +auto MatrixIterator::operator==(const MatrixIterator &rhs) const noexcept -> bool +{ + return _row_ptr == rhs._row_ptr; +} + +template +auto MatrixIterator::operator!=(const MatrixIterator &rhs) const noexcept -> bool +{ + return _row_ptr != rhs._row_ptr; +} -- cgit v1.2.3-18-g5258