From 72f422b8c83db4cdd3131510574f66c515629d8a Mon Sep 17 00:00:00 2001 From: Thomas Hahn Date: Tue, 2 Apr 2024 12:45:33 -0400 Subject: [PATCH] Implement suggested changes --- c++/itertools/product.hpp | 21 +++++++++++---------- c++/itertools/transform.hpp | 4 ++-- doc/DoxygenLayout.xml | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/c++/itertools/product.hpp b/c++/itertools/product.hpp index deae27f..f764252 100644 --- a/c++/itertools/product.hpp +++ b/c++/itertools/product.hpp @@ -51,9 +51,10 @@ namespace itertools { * - `its_end` contains the end iterators of all ranges * - `its` contains the current iterators of all ranges * - * Incrementing increments one iterator at a time in row-major order, i.e. if one iterator is equal to its - * end iterator, it is reset to its begin iterator and the previous iterator is incremented. Dereferencing - * returns a tuple containing the results of dereferencing each iterator. + * Incrementing is done from right to left, i.e. the iterator of the last range is incremented first. + * Once an iterator reaches the end of its range, it is reset to the beginning and the iterator of the + * previous range is incremented once. + * Dereferencing returns a tuple containing the results of dereferencing each iterator. * * See itertools::product(Rs &&...rgs) for more details. * @@ -87,7 +88,7 @@ namespace itertools { private: /** - * @brief Helper function which recursively increments the current iterators in row-major order. + * @brief Helper function which recursively increments the current iterators. * @tparam N Iterator index to increment. */ template void _increment() { @@ -104,7 +105,7 @@ namespace itertools { } public: - /// Increment the iterator by incrementing the current iterators in row-major order. + /// Increment the iterator by incrementing the current iterators starting with the iterator of the last range. void increment() { _increment(); } /** @@ -118,8 +119,7 @@ namespace itertools { /** * @brief Equal-to operator for a detail::prod_iter and an itertools::sentinel_t. * - * @details Since we traverse the cartesian product in row-major order, we reach the end of the product range, - * when the first iterator, i.e. `std::get<0>(its)`, is at its end. + * @details We reach the end of the product range, when the first iterator, i.e. `std::get<0>(its)`, is at its end. * * @tparam SentinelIter Iterator type of the sentinel. * @param s itertools::sentinel_t to compare with. @@ -236,9 +236,10 @@ namespace itertools { /** * @brief Lazy-multiply a given number of ranges by forming their cartesian product. * - * @details An arbitrary number of ranges are multiplied together into a cartesian product range. They are traversed in a row-major - * order, i.e. the last range is the fastest dimension. The number of elements in a product range is equal to the product of - * the sizes of the given ranges. This function returns an iterable lazy object, which can be used in range-based for loops: + * @details An arbitrary number of ranges are multiplied together into a cartesian product range. + * They are traversed such that the last range is traversed the fastest (see the example below). + * The number of elements in a product range is equal to the product of the sizes of the given ranges. + * This function returns an iterable lazy object, which can be used in range-based for loops: * * @code{.cpp} * std::vector v1 { 1, 2, 3 }; diff --git a/c++/itertools/transform.hpp b/c++/itertools/transform.hpp index f0eedb3..fbdb44a 100644 --- a/c++/itertools/transform.hpp +++ b/c++/itertools/transform.hpp @@ -144,7 +144,7 @@ namespace itertools { */ [[nodiscard]] const_iterator cbegin() const noexcept { return {std::cbegin(rg), lambda}; } - /// Non-const version of cbegin(). + /// The same as cbegin(). [[nodiscard]] const_iterator begin() const noexcept { return cbegin(); } /** @@ -153,7 +153,7 @@ namespace itertools { */ [[nodiscard]] auto cend() const noexcept { return make_sentinel(std::cend(rg)); } - /// Non-const version of cend(). + /// The same as cend(). [[nodiscard]] auto end() const noexcept { return cend(); } }; diff --git a/doc/DoxygenLayout.xml b/doc/DoxygenLayout.xml index 0e400d5..919cbeb 100644 --- a/doc/DoxygenLayout.xml +++ b/doc/DoxygenLayout.xml @@ -1,6 +1,6 @@ - +