hpx::partition#
Defined in header hpx/algorithm.hpp.
See Public API for a list of names and headers that are part of the public HPX API.
See also:
-
template<typename FwdIter, typename Pred, typename Proj = hpx::identity>
FwdIter hpx::partition(FwdIter first, FwdIter last, Pred &&pred, Proj &&proj = Proj())# Reorders the elements in the range [first, last) in such a way that all elements for which the predicate pred returns true precede the elements for which the predicate pred returns false. Relative order of the elements is not preserved.
The assignments in the parallel partition algorithm invoked without an execution policy object execute in sequential order in the calling thread.
Note
Complexity: At most 2 * (last - first) swaps. Exactly last - first applications of the predicate and projection.
- Template Parameters:
FwdIter – The type of the source iterators used (deduced). This iterator type must meet the requirements of a forward iterator.
Pred – The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of partition requires Pred to meet the requirements of CopyConstructible.
Proj – The type of an optional projection function. This defaults to hpx::identity
- 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.
pred – Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is an unary predicate for partitioning the source iterators. The signature of this predicate should be equivalent to:
The signature does not need to have const&, but the function must not modify the objects passed to it. The type Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type.bool pred(const Type &a);
proj – Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.
- Returns:
The partition algorithm returns returns FwdIter. The partition algorithm returns the iterator to the first element of the second group.
-
template<typename ExPolicy, typename FwdIter, typename Pred, typename Proj = hpx::identity>
parallel::util::detail::algorithm_result_t<ExPolicy, FwdIter> hpx::partition(ExPolicy &&policy, FwdIter first, FwdIter last, Pred &&pred, Proj &&proj = Proj())# Reorders the elements in the range [first, last) in such a way that all elements for which the predicate pred returns true precede the elements for which the predicate pred returns false. Relative order of the elements is not preserved.
The assignments in the parallel partition algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.
The assignments in the parallel partition 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: At most 2 * (last - first) swaps. Exactly last - first applications of the predicate and projection.
- 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.
FwdIter – The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.
Pred – The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of partition requires Pred to meet the requirements of CopyConstructible.
Proj – The type of an optional projection function. This defaults to hpx::identity
- 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.
pred – Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is an unary predicate for partitioning the source iterators. The signature of this predicate should be equivalent to:
The signature does not need to have const&, but the function must not modify the objects passed to it. The type Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type.bool pred(const Type &a);
proj – Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.
- Returns:
The partition algorithm returns a hpx::future<FwdIter> if the execution policy is of type parallel_task_policy and returns FwdIter otherwise. The partition algorithm returns the iterator to the first element of the second group.