hpx::reverse, hpx::reverse_copy
hpx::reverse, hpx::reverse_copy#
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
Functions
-
template<typename BidirIter>
void reverse(BidirIter first, BidirIter last)# Reverses the order of the elements in the range [first, last). Behaves as if applying std::iter_swap to every pair of iterators first+i, (last-i) - 1 for each non-negative i < (last-first)/2.
The assignments in the parallel reverse algorithm execute in sequential order in the calling thread.
Note
Complexity: Linear in the distance between first and last.
- Template Parameters
BidirIter – The type of the source iterators used (deduced). This iterator type must meet the requirements of a bidirectional iterator.
- 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.
- Returns
The reverse algorithm returns void.
-
template<typename ExPolicy, typename BidirIter>
hpx::parallel::util::detail::algorithm_result_t<ExPolicy, void> reverse(ExPolicy &&policy, BidirIter first, BidirIter last)# Reverses the order of the elements in the range [first, last). Behaves as if applying std::iter_swap to every pair of iterators first+i, (last-i) - 1 for each non-negative i < (last-first)/2. Executed according to the policy.
The assignments in the parallel reverse algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
The assignments in the parallel reverse algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
Note
Complexity: Linear in the distance between first and last.
- Template Parameters
ExPolicy – The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
BidirIter – The type of the source iterators used (deduced). This iterator type must meet the requirements of a bidirectional iterator.
- Parameters
policy – The execution policy to use for the scheduling of the iterations.
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.
- Returns
The reverse algorithm returns a hpx::future<void> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns void otherwise.
-
template<typename BidirIter, typename OutIter>
OutIter reverse_copy(BidirIter first, BidirIter last, OutIter dest)# Copies the elements from the range [first, last) to another range beginning at dest in such a way that the elements in the new range are in reverse order. Behaves as if by executing the assignment *(dest + (last - first) - 1 - i) = *(first + i) once for each non-negative i < (last - first) If the source and destination ranges (that is, [first, last) and [dest, dest+(last-first)) respectively) overlap, the behavior is undefined.
The assignments in the parallel reverse_copy algorithm execute in sequential order in the calling thread.
Note
Complexity: Performs exactly last - first assignments.
- Template Parameters
BidirIter – The type of the source iterators used (deduced). This iterator type must meet the requirements of a bidirectional iterator.
OutIter – The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an output iterator.
- 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.
dest – Refers to the begin of the destination range.
- Returns
The reverse_copy algorithm returns an OutIter. The reverse_copy algorithm returns the output iterator to the element in the destination range, one past the last element copied.
-
template<typename ExPolicy, typename BidirIter, typename FwdIter>
hpx::parallel::util::detail::algorithm_result_t<ExPolicy, FwdIter> reverse_copy(ExPolicy &&policy, BidirIter first, BidirIter last, FwdIter dest)# Copies the elements from the range [first, last) to another range beginning at dest in such a way that the elements in the new range are in reverse order. Behaves as if by executing the assignment *(dest + (last - first) - 1 - i) = *(first + i) once for each non-negative i < (last - first) If the source and destination ranges (that is, [first, last) and [dest, dest+(last-first)) respectively) overlap, the behavior is undefined. Executed according to the policy.
The assignments in the parallel reverse_copy algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
The assignments in the parallel reverse_copy algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
Note
Complexity: Performs exactly last - first assignments.
- Template Parameters
ExPolicy – The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.
BidirIter – The type of the source iterators used (deduced). This iterator type must meet the requirements of a bidirectional iterator.
FwdIter – The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of a forward iterator.
- Parameters
policy – The execution policy to use for the scheduling of the iterations.
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.
dest – Refers to the begin of the destination range.
- Returns
The reverse_copy algorithm returns a hpx::future<FwdIter> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns FwdIter otherwise. The reverse_copy algorithm returns the output iterator to the element in the destination range, one past the last element copied.
-
template<typename BidirIter>