hpx::ranges::fold_left, hpx::ranges::fold_left_first, hpx::ranges::fold_right, hpx::ranges::fold_right_last, hpx::ranges::fold_left_with_iter, hpx::ranges::fold_left_first_with_iter#
Defined in header hpx/algorithm.hpp.
See Public API for a list of names and headers that are part of the public HPX API.
-
namespace hpx
-
namespace ranges
Functions
-
template<typename InIter, typename Sent, typename T, typename F>
auto fold_left(InIter first, Sent last, T init, F f)# Left-folds a range of elements using a binary operator.
Note
Complexity: Exactly N applications of the binary operator, where N = std::distance(first, last).
- Template Parameters
InIter – The type of the source begin iterator (deduced). This iterator must meet the requirements of an input iterator.
Sent – The type of the source sentinel (deduced). This sentinel type must be a sentinel for InIter.
T – The type of the initial value.
F – The type of the binary function object.
- Parameters
first – Refers to the beginning of the sequence of elements the algorithm will be applied to.
last – Refers to the end of the sequence of elements the algorithm will be applied to.
init – The initial value for the fold operation.
f – Binary function object that will be applied.
- Returns
The result of left-folding the range.
-
template<typename Rng, typename T, typename F>
auto fold_left(Rng &&rng, T init, F f)# Left-folds a range of elements using a binary operator.
Note
Complexity: Exactly N applications of the binary operator, where N = std::distance(begin(rng), end(rng)).
- Template Parameters
Rng – The type of the source range (deduced).
T – The type of the initial value.
F – The type of the binary function object.
- Parameters
rng – Refers to the sequence of elements the algorithm will be applied to.
init – The initial value for the fold operation.
f – Binary function object that will be applied.
- Returns
The result of left-folding the range.
-
template<typename InIter, typename Sent, typename F>
auto fold_left_first(InIter first, Sent last, F f)# Left-folds a range using the first element as the initial value.
Note
Complexity: Exactly N-1 applications of the binary operator, where N = std::distance(first, last).
- Template Parameters
InIter – The type of the source begin iterator (deduced).
Sent – The type of the source sentinel (deduced).
F – The type of the binary function object.
- Parameters
first – Refers to the beginning of the sequence.
last – Refers to the end of the sequence.
f – Binary function object that will be applied.
- Returns
An optional containing the fold result, or std::nullopt if the range is empty.
-
template<typename Rng, typename F>
auto fold_left_first(Rng &&rng, F f)# Left-folds a range using the first element as the initial value.
- Template Parameters
Rng – The type of the source range (deduced).
F – The type of the binary function object.
- Parameters
rng – Refers to the sequence of elements.
f – Binary function object that will be applied.
- Returns
An optional containing the fold result, or std::nullopt if the range is empty.
-
template<typename BidIter, typename Sent, typename T, typename F>
auto fold_right(BidIter first, Sent last, T init, F f)# Right-folds a range of elements using a binary operator.
Note
Complexity: Exactly N applications of the binary operator.
- Template Parameters
BidIter – The type of the source begin iterator (deduced). This iterator must meet the requirements of a bidirectional iterator.
Sent – The type of the source sentinel (deduced).
T – The type of the initial value.
F – The type of the binary function object.
- Parameters
first – Refers to the beginning of the sequence.
last – Refers to the end of the sequence.
init – The initial value for the fold operation.
f – Binary function object that will be applied.
- Returns
The result of right-folding the range.
-
template<typename Rng, typename T, typename F>
auto fold_right(Rng &&rng, T init, F f)# Right-folds a range of elements using a binary operator.
- Template Parameters
Rng – The type of the source range (deduced).
T – The type of the initial value.
F – The type of the binary function object.
- Parameters
rng – Refers to the sequence of elements.
init – The initial value for the fold operation.
f – Binary function object that will be applied.
- Returns
The result of right-folding the range.
-
template<typename BidIter, typename Sent, typename F>
auto fold_right_last(BidIter first, Sent last, F f)# Right-folds a range using the last element as the initial value.
- Template Parameters
BidIter – The type of the source begin iterator (deduced).
Sent – The type of the source sentinel (deduced).
F – The type of the binary function object.
- Parameters
first – Refers to the beginning of the sequence.
last – Refers to the end of the sequence.
f – Binary function object that will be applied.
- Returns
An optional containing the fold result, or std::nullopt if the range is empty.
-
template<typename Rng, typename F>
auto fold_right_last(Rng &&rng, F f)# Right-folds a range using the last element as the initial value.
- Template Parameters
Rng – The type of the source range (deduced).
F – The type of the binary function object.
- Parameters
rng – Refers to the sequence of elements.
f – Binary function object that will be applied.
- Returns
An optional containing the fold result, or std::nullopt if the range is empty.
-
template<typename InIter, typename Sent, typename T, typename F>
auto fold_left_with_iter(InIter first, Sent last, T init, F f) -> fold_left_with_iter_result<InIter, std::decay_t<hpx::util::invoke_result_t<F&, T, hpx::traits::iter_reference_t<InIter>>>># Left-folds a range and returns both the result and the end iterator.
- Template Parameters
InIter – The type of the source begin iterator (deduced).
Sent – The type of the source sentinel (deduced).
T – The type of the initial value.
F – The type of the binary function object.
- Parameters
first – Refers to the beginning of the sequence.
last – Refers to the end of the sequence.
init – The initial value for the fold operation.
f – Binary function object that will be applied.
- Returns
A fold_left_with_iter_result containing the end iterator and the fold result.
-
template<typename Rng, typename T, typename F>
auto fold_left_with_iter(Rng &&rng, T init, F f) -> fold_left_with_iter_result<std::ranges::iterator_t<Rng>, std::decay_t<hpx::util::invoke_result_t<F&, T, hpx::traits::range_reference_t<Rng>>>># Left-folds a range and returns both the result and the end iterator.
- Template Parameters
Rng – The type of the source range (deduced).
T – The type of the initial value.
F – The type of the binary function object.
- Parameters
rng – Refers to the sequence of elements.
init – The initial value for the fold operation.
f – Binary function object that will be applied.
- Returns
A fold_left_with_iter_result containing the end iterator and the fold result.
-
template<typename InIter, typename Sent, typename F>
auto fold_left_first_with_iter(InIter first, Sent last, F f) -> fold_left_first_with_iter_result<InIter, hpx::optional<std::decay_t<hpx::util::invoke_result_t<F&, hpx::traits::iter_reference_t<InIter>, hpx::traits::iter_reference_t<InIter>>>>># Left-folds a range using the first element and returns both an optional result and the end iterator.
- Template Parameters
InIter – The type of the source begin iterator (deduced).
Sent – The type of the source sentinel (deduced).
F – The type of the binary function object.
- Parameters
first – Refers to the beginning of the sequence.
last – Refers to the end of the sequence.
f – Binary function object that will be applied.
- Returns
A fold_left_first_with_iter_result containing the end iterator and an optional with the fold result.
-
template<typename Rng, typename F>
auto fold_left_first_with_iter(Rng &&rng, F f) -> fold_left_first_with_iter_result<std::ranges::iterator_t<Rng>, hpx::optional<std::decay_t<hpx::util::invoke_result_t<F&, hpx::traits::range_reference_t<Rng>, hpx::traits::range_reference_t<Rng>>>>># Left-folds a range using the first element and returns both an optional result and the end iterator.
- Template Parameters
Rng – The type of the source range (deduced).
F – The type of the binary function object.
- Parameters
rng – Refers to the sequence of elements.
f – Binary function object that will be applied.
- Returns
A fold_left_first_with_iter_result containing the end iterator and an optional with the fold result.
-
template<typename InIter, typename Sent, typename T, typename F>
-
namespace ranges