diff --git a/libs/patch/PatchIterators.h b/libs/patch/PatchIterators.h index a45e34873a..02fda363f6 100644 --- a/libs/patch/PatchIterators.h +++ b/libs/patch/PatchIterators.h @@ -151,36 +151,36 @@ class SinglePatchColumnIterator : } }; -// An iterator traversing a the given patch column-wise, iterating over -// one row after the other (which are optionally constrained to [startRow..endRow]) +// An iterator traversing a given patch column-wise, iterating over +// one column after the other (which are optionally constrained to [startColumn..endColumn]) class ColumnWisePatchIterator : public PatchControlIterator { public: ColumnWisePatchIterator(IPatch& patch) : - ColumnWisePatchIterator(patch, 0, patch.getHeight() - 1) + ColumnWisePatchIterator(patch, 0, patch.getWidth() - 1) { - assert(patch.getHeight() > 0); + assert(patch.getWidth() > 0); } - ColumnWisePatchIterator(IPatch& patch, std::size_t startRow, std::size_t endRow) : - PatchControlIterator(patch, startRow, 0, - std::bind(ColumnWisePatchIterator::moveNext, std::placeholders::_1, std::ref(patch), endRow)) + ColumnWisePatchIterator(IPatch& patch, std::size_t startColumn, std::size_t endColumn) : + PatchControlIterator(patch, 0, startColumn, + std::bind(ColumnWisePatchIterator::moveNext, std::placeholders::_1, std::ref(patch), endColumn)) {} private: - static void moveNext(PatchControlIterator& it, const IPatch& patch, std::size_t endRow) + static void moveNext(PatchControlIterator& it, const IPatch& patch, std::size_t endColumn) { - auto nextColumn = it.getColumn() + 1; - auto nextRow = it.getRow(); + auto nextRow = it.getRow() + 1; + auto nextColumn = it.getColumn(); - if (nextColumn >= patch.getWidth()) + if (nextRow >= patch.getHeight()) { - // Advance to the next row + // Advance to the next column // If that doesn't succeed, just leave the indices out of bounds - if (++nextRow <= endRow) + if (++nextColumn <= endColumn) { - nextColumn = 0; + nextRow = 0; } } @@ -188,36 +188,36 @@ class ColumnWisePatchIterator : } }; -// An iterator traversing a the given patch row-wise, iterating over -// one column after the other (which are optionally constrained to [startColumn..endColumn]) +// An iterator traversing a given patch row-wise, iterating over +// one row after the other (which are optionally constrained to [startRow..endRow]) class RowWisePatchIterator : public PatchControlIterator { public: RowWisePatchIterator(IPatch& patch) : - RowWisePatchIterator(patch, 0, patch.getWidth() - 1) + RowWisePatchIterator(patch, 0, patch.getHeight() - 1) { - assert(patch.getWidth() > 0); + assert(patch.getHeight() > 0); } - RowWisePatchIterator(IPatch& patch, std::size_t startColumn, std::size_t endColumn) : - PatchControlIterator(patch, startColumn, 0, - std::bind(RowWisePatchIterator::moveNext, std::placeholders::_1, std::ref(patch), endColumn)) + RowWisePatchIterator(IPatch& patch, std::size_t startRow, std::size_t endRow) : + PatchControlIterator(patch, startRow, 0, + std::bind(RowWisePatchIterator::moveNext, std::placeholders::_1, std::ref(patch), endRow)) {} private: - static void moveNext(PatchControlIterator& it, const IPatch& patch, std::size_t endColumn) + static void moveNext(PatchControlIterator& it, const IPatch& patch, std::size_t endRow) { - auto nextRow = it.getRow() + 1; - auto nextColumn = it.getColumn(); + auto nextColumn = it.getColumn() + 1; + auto nextRow = it.getRow(); - if (nextRow >= patch.getHeight()) + if (nextColumn >= patch.getWidth()) { - // Advance to the next column + // Advance to the next row // If that doesn't succeed, just leave the indices out of bounds - if (++nextColumn <= endColumn) + if (++nextRow <= endRow) { - nextRow = 0; + nextColumn = 0; } }