hpx/parallel/container_algorithms/partition.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 Rng, typename Pred, typename Proj = parallel::util::projection_identity>
subrange_t<hpx::traits::range_iterator_t<Rng>> partition(Rng &&rng, Pred &&pred, Proj &&proj = Proj())#

Reorders the elements in the range rng 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: Performs at most 2 * N swaps, exactly N applications of the predicate and projection, where N = std::distance(begin(rng), end(rng)).

Template Parameters
  • Rng – The type of the source range used (deduced). The iterators extracted from this range 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 util::projection_identity

Parameters
  • rng – Refers to 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 the range rng. This is an unary predicate for partitioning the source iterators. The signature of this predicate should be equivalent to:

    bool pred(const Type &a);
    
    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.

  • 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 subrange_t<hpx::traits::range_iterator_t<Rng>> The partition algorithm returns a subrange starting with an iterator to the first element of the second group and finishing with an iterator equal to last.

template<typename ExPolicy, typename Rng, typename Pred, typename Proj = parallel::util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, subrange_t<hpx::traits::range_iterator_t<Rng>>>::type partition(ExPolicy &&policy, Rng &&rng, Pred &&pred, Proj &&proj = Proj())#

Reorders the elements in the range rng 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: Performs at most 2 * N swaps, exactly N applications of the predicate and projection, where N = std::distance(begin(rng), end(rng)).

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.

  • Rng – The type of the source range used (deduced). The iterators extracted from this range 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 util::projection_identity

Parameters
  • policy – The execution policy to use for the scheduling of the iterations.

  • rng – Refers to 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 the range rng. This is an unary predicate for partitioning the source iterators. The signature of this predicate should be equivalent to:

    bool pred(const Type &a);
    
    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.

  • 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<subrange_t<hpx::traits::range_iterator_t<Rng>>> if the execution policy is of type parallel_task_policy and returns subrange_t<hpx::traits::range_iterator_t<Rng>> The partition algorithm returns a subrange starting with an iterator to the first element of the second group and finishing with an iterator equal to last.

template<typename FwdIter, typename Sent, typename Pred, typename Proj = parallel::util::projection_identity>
subrange_t<FwdIter> partition(FwdIter first, Sent 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 an forward iterator.

  • Sent – The type of the source sentinel (deduced). This sentinel type must be a sentinel for FwdIter.

  • 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 util::projection_identity

Parameters
  • first – Refers to the beginning of the sequence of elements the algorithm will be applied to.

  • last – Refers to sentinel value denoting the end of the sequence of elements the algorithm will be applied.

  • 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:

    bool pred(const Type &a);
    
    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 InIter can be dereferenced and then implicitly converted to Type.

  • 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 subrange_t<FwdIter>. The partition algorithm returns a subrange starting with an iterator to the first element of the second group and finishing with an iterator equal to last.

template<typename ExPolicy, typename FwdIter, typename Sent, typename Pred, typename Proj = parallel::util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, subrange_t<FwdIter>>::type partition(ExPolicy &&policy, FwdIter first, Sent 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.

  • Sent – The type of the source sentinel (deduced). This sentinel type must be a sentinel for FwdIter.

  • 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 util::projection_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 sentinel value denoting the end of the sequence of elements the algorithm will be applied.

  • 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:

    bool pred(const Type &a);
    
    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 InIter can be dereferenced and then implicitly converted to Type.

  • 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<subrange_t<FwdIter>> if the execution policy is of type parallel_task_policy and returns subrange_t<FwdIter> otherwise. The partition algorithm returns a subrange starting with an iterator to the first element of the second group and finishing with an iterator equal to last.

template<typename Rng, typename Pred, typename Proj = parallel::util::projection_identity>
subrange_t<hpx::traits::range_iterator_t<Rng>> stable_partition(Rng &&rng, Pred &&pred, Proj &&proj = Proj())#

Permutes the elements in the range [first, last) such that there exists an iterator i such that for every iterator j in the range [first, i) INVOKE(f, INVOKE (proj, *j)) != false, and for every iterator k in the range [i, last), INVOKE(f, INVOKE (proj, *k)) == false

The invocations of f in the parallel stable_partition algorithm invoked without an execution policy object executes in sequential order in the calling thread.

Note

Complexity: At most (last - first) * log(last - first) swaps, but only linear number of swaps if there is enough extra memory Exactly last - first applications of the predicate and projection.

Template Parameters
  • Rng – The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an birdirectional 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 util::projection_identity

Parameters
  • rng – Refers to the sequence of elements the algorithm will be applied to.

  • pred – Unary predicate which returns true if the element should be ordered before other elements. Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). The signature of this predicate should be equivalent to:

    bool fun(const Type &a);
    
    The signature does not need to have const&. The type Type must be such that an object of type BidirIter can be dereferenced and then implicitly converted to Type.

  • proj – Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate f is invoked.

Returns

The stable_partition algorithm returns an iterator i such that for every iterator j in the range [first, i), f(*j) != false INVOKE(f, INVOKE(proj, *j)) != false, and for every iterator k in the range [i, last), f(*k) == false INVOKE(f, INVOKE (proj, *k)) == false. The relative order of the elements in both groups is preserved.

template<typename ExPolicy, typename Rng, typename Pred, typename Proj = parallel::util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, subrange_t<hpx::traits::range_iterator_t<Rng>>>::type stable_partition(ExPolicy &&policy, Rng &&rng, Pred &&pred, Proj &&proj = Proj())#

Permutes the elements in the range [first, last) such that there exists an iterator i such that for every iterator j in the range [first, i) INVOKE(f, INVOKE (proj, *j)) != false, and for every iterator k in the range [i, last), INVOKE(f, INVOKE (proj, *k)) == false

The invocations of f in the parallel stable_partition algorithm invoked with an execution policy object of type sequenced_policy executes in sequential order in the calling thread.

The invocations of f in the parallel stable_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 (last - first) * log(last - first) swaps, but only linear number of swaps if there is enough extra memory. 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 invocations of f.

  • Rng – The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an birdirectional 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 util::projection_identity

Parameters
  • policy – The execution policy to use for the scheduling of the iterations.

  • rng – Refers to the sequence of elements the algorithm will be applied to.

  • pred – Unary predicate which returns true if the element should be ordered before other elements. Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). The signature of this predicate should be equivalent to:

    bool fun(const Type &a);
    
    The signature does not need to have const&. The type Type must be such that an object of type BidirIter can be dereferenced and then implicitly converted to Type.

  • proj – Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate f is invoked.

Returns

The stable_partition algorithm returns an iterator i such that for every iterator j in the range [first, i), f(*j) != false INVOKE(f, INVOKE(proj, *j)) != false, and for every iterator k in the range [i, last), f(*k) == false INVOKE(f, INVOKE (proj, *k)) == false. The relative order of the elements in both groups is preserved. If the execution policy is of type parallel_task_policy the algorithm returns a future<> referring to this iterator.

template<typename BidirIter, typename Sent, typename Pred, typename Proj = parallel::util::projection_identity>
subrange_t<BidirIter> stable_partition(BidirIter first, Sent last, Pred &&pred, Proj &&proj = Proj())#

Permutes the elements in the range [first, last) such that there exists an iterator i such that for every iterator j in the range [first, i) INVOKE(f, INVOKE (proj, *j)) != false, and for every iterator k in the range [i, last), INVOKE(f, INVOKE (proj, *k)) == false

The invocations of f in the parallel stable_partition algorithm invoked without an execution policy object executes in sequential order in the calling thread.

Note

Complexity: At most (last - first) * log(last - first) swaps, but only linear number of swaps if there is enough extra memory Exactly last - first applications of the predicate and projection.

Template Parameters
  • BidirIter – The type of the source iterators used (deduced). This iterator type must meet the requirements of an input iterator.

  • Sent – The type of the source sentinel (deduced). This sentinel type must be a sentinel for BidirIter.

  • 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 util::projection_identity

Parameters
  • first – Refers to the beginning of the sequence of elements the algorithm will be applied to.

  • last – Refers to sentinel value denoting the end of the sequence of elements the algorithm will be applied.

  • pred – Unary predicate which returns true if the element should be ordered before other elements. Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). The signature of this predicate should be equivalent to:

    bool fun(const Type &a);
    
    The signature does not need to have const&. The type Type must be such that an object of type BidirIter can be dereferenced and then implicitly converted to Type.

  • proj – Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate f is invoked.

Returns

The stable_partition algorithm returns an iterator i such that for every iterator j in the range [first, i), f(*j) != false INVOKE(f, INVOKE(proj, *j)) != false, and for every iterator k in the range [i, last), f(*k) == false INVOKE(f, INVOKE (proj, *k)) == false. The relative order of the elements in both groups is preserved.

template<typename ExPolicy, typename BidirIter, typename Sent, typename Pred, typename Proj = parallel::util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, subrange_t<BidirIter>>::type stable_partition(ExPolicy &&policy, BidirIter first, Sent last, Pred &&pred, Proj &&proj = Proj())#

Permutes the elements in the range [first, last) such that there exists an iterator i such that for every iterator j in the range [first, i) INVOKE(f, INVOKE (proj, *j)) != false, and for every iterator k in the range [i, last), INVOKE(f, INVOKE (proj, *k)) == false

The invocations of f in the parallel stable_partition algorithm invoked with an execution policy object of type sequenced_policy executes in sequential order in the calling thread.

The invocations of f in the parallel stable_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 (last - first) * log(last - first) swaps, but only linear number of swaps if there is enough extra memory 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 invocations of f.

  • BidirIter – The type of the source iterators used (deduced). This iterator type must meet the requirements of an input iterator.

  • Sent – The type of the source sentinel (deduced). This sentinel type must be a sentinel for BidirIter.

  • 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 util::projection_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 sentinel value denoting the end of the sequence of elements the algorithm will be applied.

  • pred – Unary predicate which returns true if the element should be ordered before other elements. Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). The signature of this predicate should be equivalent to:

    bool fun(const Type &a);
    
    The signature does not need to have const&. The type Type must be such that an object of type BidirIter can be dereferenced and then implicitly converted to Type.

  • proj – Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate f is invoked.

Returns

The stable_partition algorithm returns an iterator i such that for every iterator j in the range [first, i), f(*j) != false INVOKE(f, INVOKE(proj, *j)) != false, and for every iterator k in the range [i, last), f(*k) == false INVOKE(f, INVOKE (proj, *k)) == false. The relative order of the elements in both groups is preserved. If the execution policy is of type parallel_task_policy the algorithm returns a future<> referring to this iterator.

template<typename Rng, typename OutIter2, typename OutIter3, typename Pred, typename Proj = parallel::util::projection_identity>
partition_copy_result<hpx::traits::range_iterator_t<Rng>, OutIter2, OutIter3> partition_copy(Rng &&rng, OutIter2 dest_true, OutIter3 dest_false, Pred &&pred, Proj &&proj = Proj())#

Copies the elements in the range rng, to two different ranges depending on the value returned by the predicate pred. The elements, that satisfy the predicate pred are copied to the range beginning at dest_true. The rest of the elements are copied to the range beginning at dest_false. The order of the elements is preserved.

The assignments in the parallel partition_copy algorithm invoked without an execution policy object execute in sequential order in the calling thread.

Note

Complexity: Performs not more than N assignments, exactly N applications of the predicate pred, where N = std::distance(begin(rng), end(rng)).

Template Parameters
  • Rng – The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an forward iterator.

  • OutIter2 – The type of the iterator representing the destination range for the elements that satisfy the predicate pred (deduced). This iterator type must meet the requirements of an forward iterator.

  • OutIter3 – The type of the iterator representing the destination range for the elements that don’t satisfy the predicate pred (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_copy requires Pred to meet the requirements of CopyConstructible.

  • Proj – The type of an optional projection function. This defaults to util::projection_identity

Parameters
  • rng – Refers to the sequence of elements the algorithm will be applied to.

  • dest_true – Refers to the beginning of the destination range for the elements that satisfy the predicate pred

  • dest_false – Refers to the beginning of the destination range for the elements that don’t satisfy the predicate pred.

  • 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:

    bool pred(const Type &a);
    
    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 FwdIter1 can be dereferenced and then implicitly converted to Type.

  • 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_copy algorithm returns a partition_copy_result<hpx::traits::range_iterator_t<Rng>, FwdIter2, FwdIter3>>. The partition_copy algorithm returns the tuple of the source iterator last, the destination iterator to the end of the dest_true range, and the destination iterator to the end of the dest_false range.

template<typename ExPolicy, typename Rng, typename FwdIter2, typename FwdIter3, typename Pred, typename Proj = parallel::util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, partition_copy_result<hpx::traits::range_iterator_t<Rng>, FwdIter2, FwdIter3>>::type partition_copy(ExPolicy &&policy, Rng &&rng, FwdIter2 dest_true, FwdIter3 dest_false, Pred &&pred, Proj &&proj = Proj())#

Copies the elements in the range rng, to two different ranges depending on the value returned by the predicate pred. The elements, that satisfy the predicate pred are copied to the range beginning at dest_true. The rest of the elements are copied to the range beginning at dest_false. The order of the elements is preserved.

The assignments in the parallel partition_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 partition_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 not more than N assignments, exactly N applications of the predicate pred, where N = std::distance(begin(rng), end(rng)).

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.

  • Rng – The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an forward iterator.

  • FwdIter2 – The type of the iterator representing the destination range for the elements that satisfy the predicate pred (deduced). This iterator type must meet the requirements of an forward iterator.

  • FwdIter3 – The type of the iterator representing the destination range for the elements that don’t satisfy the predicate pred (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_copy requires Pred to meet the requirements of CopyConstructible.

  • Proj – The type of an optional projection function. This defaults to util::projection_identity

Parameters
  • policy – The execution policy to use for the scheduling of the iterations.

  • rng – Refers to the sequence of elements the algorithm will be applied to.

  • dest_true – Refers to the beginning of the destination range for the elements that satisfy the predicate pred

  • dest_false – Refers to the beginning of the destination range for the elements that don’t satisfy the predicate pred.

  • 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:

    bool pred(const Type &a);
    
    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 FwdIter1 can be dereferenced and then implicitly converted to Type.

  • 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_copy algorithm returns a hpx::future<partition_copy_result <hpx::traits::range_iterator_t<Rng>, FwdIter2, FwdIter3>> if the execution policy is of type parallel_task_policy and returns partition_copy_result<hpx::traits::range_iterator_t<Rng>, FwdIter2, FwdIter3> otherwise. The partition_copy algorithm returns the tuple of the source iterator last, the destination iterator to the end of the dest_true range, and the destination iterator to the end of the dest_false range.

template<typename InIter, typename Sent, typename OutIter2, typename OutIter3, typename Pred, typename Proj = parallel::util::projection_identity>
partition_copy_result<InIter, OutIter2, OutIter3> partition_copy(InIter first, Sent last, OutIter2 dest_true, OutIter3 dest_false, Pred &&pred, Proj &&proj = Proj())#

Copies the elements in the range, defined by [first, last), to two different ranges depending on the value returned by the predicate pred. The elements, that satisfy the predicate pred are copied to the range beginning at dest_true. The rest of the elements are copied to the range beginning at dest_false. The order of the elements is preserved.

The assignments in the parallel partition_copy algorithm invoked without an execution policy object execute in sequential order in the calling thread.

Note

Complexity: Performs not more than last - first assignments, exactly last - first applications of the predicate f.

Template Parameters
  • InIter – The type of the source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.

  • Sent – The type of the source sentinel (deduced). This sentinel type must be a sentinel for FwdIter.

  • OutIter2 – The type of the iterator representing the destination range for the elements that satisfy the predicate pred (deduced). This iterator type must meet the requirements of an forward iterator.

  • OutIter3 – The type of the iterator representing the destination range for the elements that don’t satisfy the predicate pred (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_copy requires Pred to meet the requirements of CopyConstructible.

  • Proj – The type of an optional projection function. This defaults to util::projection_identity

Parameters
  • first – Refers to the beginning of the sequence of elements the algorithm will be applied to.

  • last – Refers to sentinel value denoting the end of the sequence of elements the algorithm will be applied.

  • dest_true – Refers to the beginning of the destination range for the elements that satisfy the predicate pred

  • dest_false – Refers to the beginning of the destination range for the elements that don’t satisfy the predicate pred.

  • 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:

    bool pred(const Type &a);
    
    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 FwdIter1 can be dereferenced and then implicitly converted to Type.

  • 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_copy algorithm returns a partition_copy_result<FwdIter, OutIter2, OutIter3>. The partition_copy algorithm returns the tuple of the source iterator last, the destination iterator to the end of the dest_true range, and the destination iterator to the end of the dest_false range.

template<typename ExPolicy, typename FwdIter, typename Sent, typename OutIter2, typename OutIter3, typename Pred, typename Proj = parallel::util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, partition_copy_result<FwdIter, OutIter2, OutIter3>>::type partition_copy(ExPolicy &&policy, FwdIter first, Sent last, OutIter2 dest_true, OutIter3 dest_false, Pred &&pred, Proj &&proj = Proj())#

Copies the elements in the range, defined by [first, last), to two different ranges depending on the value returned by the predicate pred. The elements, that satisfy the predicate pred are copied to the range beginning at dest_true. The rest of the elements are copied to the range beginning at dest_false. The order of the elements is preserved.

The assignments in the parallel partition_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 partition_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 not more than last - first assignments, exactly last - first applications of the predicate f.

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.

  • Sent – The type of the source sentinel (deduced). This sentinel type must be a sentinel for FwdIter.

  • OutIter2 – The type of the iterator representing the destination range for the elements that satisfy the predicate pred (deduced). This iterator type must meet the requirements of an forward iterator.

  • OutIter3 – The type of the iterator representing the destination range for the elements that don’t satisfy the predicate pred (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_copy requires Pred to meet the requirements of CopyConstructible.

  • Proj – The type of an optional projection function. This defaults to util::projection_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 sentinel value denoting the end of the sequence of elements the algorithm will be applied.

  • dest_true – Refers to the beginning of the destination range for the elements that satisfy the predicate pred

  • dest_false – Refers to the beginning of the destination range for the elements that don’t satisfy the predicate pred.

  • 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:

    bool pred(const Type &a);
    
    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 FwdIter1 can be dereferenced and then implicitly converted to Type.

  • 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_copy algorithm returns a hpx::future<partition_copy_result<FwdIter, OutIter2, OutIter3>> if the execution policy is of type parallel_task_policy and returns partition_copy_result<FwdIter, OutIter2, OutIter3> otherwise. The partition_copy algorithm returns the tuple of the source iterator last, the destination iterator to the end of the dest_true range, and the destination iterator to the end of the dest_false range.