Skip to content

Commit

Permalink
Implement suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Thoemi09 committed Apr 2, 2024
1 parent 98d07e1 commit 72f422b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
21 changes: 11 additions & 10 deletions c++/itertools/product.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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 <int N> void _increment() {
Expand All @@ -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<Rank - 1>(); }

/**
Expand All @@ -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.
Expand Down Expand Up @@ -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<int> v1 { 1, 2, 3 };
Expand Down
4 changes: 2 additions & 2 deletions c++/itertools/transform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }

/**
Expand All @@ -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(); }
};

Expand Down
2 changes: 1 addition & 1 deletion doc/DoxygenLayout.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<doxygenlayout version="1.0">
<!-- Generated by doxygen 1.11.0 -->
<!-- Customized for itertools after being generated by doxygen 1.11.0 -->
<!-- Navigation index tabs for HTML output -->
<navindex>
<tab type="usergroup" url="@ref installation" title="Installation">
Expand Down

0 comments on commit 72f422b

Please sign in to comment.