Skip to content

Commit

Permalink
Simplify docs of private/hidden entities
Browse files Browse the repository at this point in the history
  • Loading branch information
Thoemi09 committed Apr 2, 2024
1 parent 72f422b commit 99fea9a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 53 deletions.
4 changes: 2 additions & 2 deletions c++/itertools/iterator_facade.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ namespace itertools {
template <typename Iter, typename Value, typename Reference, typename Difference>
struct iterator_facade<Iter, Value, std::forward_iterator_tag, Reference, Difference> {
private:
/// Get a reference to the derived iterator.
// Get a reference to the derived iterator.
[[nodiscard]] Iter &self() { return static_cast<Iter &>(*this); }

/// Get a const reference to the derived iterator.
// Get a const reference to the derived iterator.
[[nodiscard]] Iter const &self() const { return static_cast<const Iter &>(*this); }

public:
Expand Down
22 changes: 5 additions & 17 deletions c++/itertools/product.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ namespace itertools {
prod_iter(std::tuple<Iters...> its_begin, EndIters its_end) : its_begin(std::move(its_begin)), its_end(std::move(its_end)) {}

private:
/**
* @brief Helper function which recursively increments the current iterators.
* @tparam N Iterator index to increment.
*/
// Helper function to recursively increment the current iterators.
template <int N> void _increment() {
// increment Nth iterator
++std::get<N>(its);
Expand Down Expand Up @@ -128,10 +125,7 @@ namespace itertools {
template <typename SentinelIter> [[nodiscard]] bool operator==(sentinel_t<SentinelIter> const &s) const { return (s.it == std::get<0>(its)); }

private:
/**
* @brief Helper function to dereference all original iterators.
* @return Tuple containing the dereferenced values of all original iterators.
*/
// Helper function to dereference all original iterators.
template <size_t... Is> [[gnu::always_inline]] [[nodiscard]] auto tuple_map_impl(std::index_sequence<Is...>) const {
return std::tuple<decltype(*std::get<Is>(its))...>(*std::get<Is>(its)...);
}
Expand Down Expand Up @@ -174,12 +168,12 @@ namespace itertools {
[[nodiscard]] bool operator==(multiplied const &) const = default;

private:
/// Helper function to create a detail::prod_iter representing the beginning of the product range.
// Helper function to create a detail::prod_iter representing the beginning of the product range.
template <size_t... Is> [[gnu::always_inline]] auto _begin(std::index_sequence<Is...>) {
return iterator{std::make_tuple(std::begin(std::get<Is>(tu))...), std::make_tuple(std::end(std::get<Is>(tu))...)};
}

/// Const version of _begin(std::index_sequence<Is...>).
// Const version of _begin(std::index_sequence<Is...>).
template <size_t... Is> [[gnu::always_inline]] auto _cbegin(std::index_sequence<Is...>) const {
return const_iterator{std::make_tuple(std::cbegin(std::get<Is>(tu))...), std::make_tuple(std::cend(std::get<Is>(tu))...)};
}
Expand Down Expand Up @@ -214,13 +208,7 @@ namespace itertools {
// Class template argument deduction guide.
template <typename... Rs> multiplied(Rs &&...) -> multiplied<std::decay_t<Rs>...>;

/**
* @brief Helper function to create a product range from a container of ranges.
*
* @tparam C Container type.
* @param cont Container of ranges.
* @return Product range from the ranges in the container.
*/
// Helper function to create a product range from a container of ranges.
template <typename C, size_t... Is> [[gnu::always_inline]] [[nodiscard]] auto make_product_impl(C &cont, std::index_sequence<Is...>) {
return product(cont[Is]...);
}
Expand Down
26 changes: 10 additions & 16 deletions c++/itertools/range.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ namespace itertools {
* See also <a href="https://en.cppreference.com/w/cpp/ranges/iota_view">std::ranges::views::iota</a>.
*/
class range {
/// First value of the range.
// First value of the range.
long first_ = 0;

/// Last value of the range (excluded).
// Last value of the range (excluded).
long last_ = -1;

/// Number of integers between two elements of the range.
// Number of integers between two elements of the range.
long step_ = 1;

public:
Expand Down Expand Up @@ -258,19 +258,19 @@ namespace itertools {
* @brief Beginning of the integer range.
* @return Iterator with its current value set to the first value of the range.
*/
[[nodiscard]] const_iterator begin() const noexcept { return {first_, last_, step_}; }

/// Const version of begin().
[[nodiscard]] const_iterator cbegin() const noexcept { return {first_, last_, step_}; }

/// The same as cbegin().
[[nodiscard]] const_iterator begin() const noexcept { return {first_, last_, step_}; }

/**
* @brief End of the range.
* @return Iterator with its current value set to the excluded last value of the range.
*/
[[nodiscard]] const_iterator end() const noexcept { return {last_, last_, step_}; }

/// Const version of end().
[[nodiscard]] const_iterator cend() const noexcept { return {last_, last_, step_}; }

/// The same as cend().
[[nodiscard]] const_iterator end() const noexcept { return {last_, last_, step_}; }
};

/**
Expand Down Expand Up @@ -307,13 +307,7 @@ namespace itertools {
/// @cond
namespace detail {

/**
* @brief Helper function to create a product range of integer ranges from a tuple or an array.
*
* @tparam T Tuple or array type.
* @param idxs Tuple or array containing the excluded last values of the itertools::range objects.
* @return Product (detail::multiplied) range of integer ranges.
*/
// Helper function to create a product range of integer ranges from a tuple or an array.
template <typename T, size_t... Is> [[gnu::always_inline]] auto product_range_impl(T const &idxs, std::index_sequence<Is...>) {
return product_range(std::get<Is>(idxs)...);
}
Expand Down
5 changes: 1 addition & 4 deletions c++/itertools/stride.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,7 @@ namespace itertools {
[[nodiscard]] bool operator==(strided const &) const = default;

private:
/**
* @brief Helper function to calculate the index of the end iterator.
* @return Index of the end iterator.
*/
// Helper function to calculate the index of the end iterator.
[[nodiscard]] std::ptrdiff_t end_offset() const {
auto size = distance(std::cbegin(rg), std::cend(rg));
return (size == 0) ? 0 : ((size - 1) / stride + 1) * stride;
Expand Down
18 changes: 4 additions & 14 deletions c++/itertools/zip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace itertools {
zip_iter(std::tuple<Iters...> its) : its(std::move(its)) {}

private:
/// Helper function which increments all original iterators.
// Helper function which increments all original iterators.
template <size_t... Is> [[gnu::always_inline]] void increment_all(std::index_sequence<Is...>) { ((void)(++std::get<Is>(its)), ...); }

public:
Expand Down Expand Up @@ -92,10 +92,7 @@ namespace itertools {
}

private:
/**
* @brief Helper function to dereference all original iterators.
* @return Tuple containing the dereferenced values of all original iterators.
*/
// Helper function to dereference all original iterators.
template <size_t... Is> [[nodiscard]] auto tuple_map_impl(std::index_sequence<Is...>) const {
return std::tuple<decltype(*std::get<Is>(its))...>(*std::get<Is>(its)...);
}
Expand Down Expand Up @@ -141,19 +138,12 @@ namespace itertools {
[[nodiscard]] bool operator==(zipped const &) const = default;

private:
/**
* @brief Helper function that applies a given callable to each range in the stored tuple and returns a
* new tuple with the results.
*
* @tparam F Callable type.
* @param f Callable object.
* @return Tuple containing the mapped tuple elements after applying the callable.
*/
// Helper function that applies a given callable to each range in the stored tuple and returns a new tuple with the results.
template <typename F, size_t... Is> [[gnu::always_inline]] auto tuple_map(F &&f, std::index_sequence<Is...>) {
return std::make_tuple(std::forward<F>(f)(std::get<Is>(tu))...);
}

/// Const overload of tuple_map(F &&, std::index_sequence<Is...>).
// Const overload of tuple_map(F &&, std::index_sequence<Is...>).
template <typename F, size_t... Is> [[gnu::always_inline]] auto tuple_map(F &&f, std::index_sequence<Is...>) const {
return std::make_tuple(std::forward<F>(f)(std::get<Is>(tu))...);
}
Expand Down

0 comments on commit 99fea9a

Please sign in to comment.