hpx/parallel/container_algorithms/partial_sort_copy.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 Sent1, typename RandIter, typename Sent2, typename Comp = ranges::less, typename Proj1 = parallel::util::projection_identity, typename Proj2 = parallel::util::projection_identity>
partial_sort_copy_result<InIter, RandIter> partial_sort_copy(InIter first, Sent1 last, RandIter r_first, Sent2 r_last, Comp &&comp = Comp(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())#

Sorts some of the elements in the range [first, last) in ascending order, storing the result in the range [r_first, r_last). At most r_last - r_first of the elements are placed sorted to the range [r_first, r_first + n) where n is the number of elements to sort (n = min(last - first, r_last - r_first)).

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

Note

Complexity: O(Nlog(min(D,N))), where N = std::distance(first, last) and D = std::distance(r_first, r_last) comparisons.

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

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

  • RandIter – The type of the destination iterators used(deduced) This iterator type must meet the requirements of an random iterator.

  • Sent2 – The type of the destination sentinel (deduced).This sentinel type must be a sentinel for RandIter.

  • Comp – The type of the function/function object to use (deduced). Comp defaults to detail::less.

  • Proj1 – The type of an optional projection function for the input range. This defaults to util::projection_identity.

  • Proj1 – The type of an optional projection function for the output range. 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 the sentinel value denoting the end of the sequence of elements the algorithm will be applied to.

  • r_first – Refers to the beginning of the destination range.

  • r_last – Refers to the sentinel denoting the end of the destination range.

  • comp – comp is a callable object. The return value of the INVOKE operation applied to an object of type Comp, when contextually converted to bool, yields true if the first argument of the call is less than the second, and false otherwise. It is assumed that comp will not apply any non-constant function through the dereferenced iterator. This defaults to detail::less.

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

  • proj2 – Specifies the function (or function object) which will be invoked for each pair of elements as a projection operation after the actual predicate comp is invoked.

Returns

The partial_sort_copy algorithm returns a returns partial_sort_copy_result<InIter, RandIter>. The algorithm returns {last, result_first + N}.

template<typename ExPolicy, typename FwdIter, typename Sent1, typename RandIter, typename Sent2, typename Comp = ranges::less, typename Proj1 = parallel::util::projection_identity, typename Proj2 = parallel::util::projection_identity>
parallel::util::detail::algorithm_result_t<ExPolicy, partial_sort_copy_result<FwdIter, RandIter>> partial_sort_copy(ExPolicy &&policy, FwdIter first, Sent1 last, RandIter r_first, Sent2 r_last, Comp &&comp = Comp(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())#

Sorts some of the elements in the range [first, last) in ascending order, storing the result in the range [r_first, r_last). At most r_last - r_first of the elements are placed sorted to the range [r_first, r_first + n) where n is the number of elements to sort (n = min(last - first, r_last - r_first)).

The application of function objects in parallel algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.

The application of function objects in parallel 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: O(Nlog(min(D,N))), where N = std::distance(first, last) and D = std::distance(r_first, r_last) comparisons.

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.

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

  • RandIter – The type of the destination iterators used(deduced) This iterator type must meet the requirements of an random iterator.

  • Sent2 – The type of the destination sentinel (deduced).This sentinel type must be a sentinel for RandIter.

  • Comp – The type of the function/function object to use (deduced). Comp defaults to detail::less.

  • Proj1 – The type of an optional projection function for the input range. This defaults to util::projection_identity.

  • Proj1 – The type of an optional projection function for the output range. 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 the sentinel value denoting the end of the sequence of elements the algorithm will be applied to.

  • r_first – Refers to the beginning of the destination range.

  • r_last – Refers to the sentinel denoting the end of the destination range.

  • comp – comp is a callable object. The return value of the INVOKE operation applied to an object of type Comp, when contextually converted to bool, yields true if the first argument of the call is less than the second, and false otherwise. It is assumed that comp will not apply any non-constant function through the dereferenced iterator. This defaults to detail::less.

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

  • proj2 – Specifies the function (or function object) which will be invoked for each pair of elements as a projection operation after the actual predicate comp is invoked.

Returns

The partial_sort_copy algorithm returns a hpx::future<partial_sort_copy_result<FwdIter, RandIter>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns partial_sort_copy_result<FwdIter, RandIter> otherwise. The algorithm returns {last, result_first + N}.

template<typename Rng1, typename Rng2, typename Comp = ranges::less, typename Proj1 = parallel::util::projection_identity, typename Proj2 = parallel::util::projection_identity>
partial_sort_copy_result<hpx::traits::range_iterator_t<Rng1>, hpx::traits::range_iterator_t<Rng2>> partial_sort_copy(Rng1 &&rng1, Rng2 &&rng2, Comp &&comp = Comp(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())#

Sorts some of the elements in the range [first, last) in ascending order, storing the result in the range [r_first, r_last). At most r_last - r_first of the elements are placed sorted to the range [r_first, r_first + n) where n is the number of elements to sort (n = min(last - first, r_last - r_first)).

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

Note

Complexity: O(Nlog(min(D,N))), where N = std::distance(first, last) and D = std::distance(r_first, r_last) comparisons.

Template Parameters
  • Rng1 – The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of a input iterator.

  • Rng2 – The type of the destination range used (deduced). The iterators extracted from this range type must meet the requirements of a random iterator.

  • Comp – The type of the function/function object to use (deduced). Comp defaults to detail::less.

  • Proj1 – The type of an optional projection function for the input range. This defaults to util::projection_identity.

  • Proj2 – The type of an optional projection function for the output range. This defaults to util::projection_identity.

Parameters
  • rng1 – Refers to the source range.

  • rng2 – Refers to the destination range.

  • comp – comp is a callable object. The return value of the INVOKE operation applied to an object of type Comp, when contextually converted to bool, yields true if the first argument of the call is less than the second, and false otherwise. It is assumed that comp will not apply any non-constant function through the dereferenced iterator. This defaults to detail::less.

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

  • proj2 – Specifies the function (or function object) which will be invoked for each pair of elements as a projection operation after the actual predicate comp is invoked.

Returns

The partial_sort_copy algorithm returns partial_sort_copy_result<range_iterator_t<Rng1>, range_iterator_t<Rng2>>. The algorithm returns {last, result_first + N}.

template<typename ExPolicy, typename Rng1, typename Rng2, typename Comp = ranges::less, typename Proj1 = parallel::util::projection_identity, typename Proj2 = parallel::util::projection_identity>
parallel::util::detail::algorithm_result_t<ExPolicy, partial_sort_copy_result<hpx::traits::range_iterator_t<Rng1>, hpx::traits::range_iterator_t<Rng2>>> partial_sort_copy(ExPolicy &&policy, Rng1 &&rng1, Rng2 &&rng2, Comp &&comp = Comp(), Proj1 &&proj1 = Proj1(), Proj2 &&proj2 = Proj2())#

Sorts some of the elements in the range [first, last) in ascending order, storing the result in the range [r_first, r_last). At most r_last - r_first of the elements are placed sorted to the range [r_first, r_first + n) where n is the number of elements to sort (n = min(last - first, r_last - r_first)).

The application of function objects in parallel algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.

The application of function objects in parallel 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: O(Nlog(min(D,N))), where N = std::distance(first, last) and D = std::distance(r_first, r_last) comparisons.

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.

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

  • Rng2 – The type of the destination range used (deduced). The iterators extracted from this range type must meet the requirements of a random iterator.

  • Comp – The type of the function/function object to use (deduced). Comp defaults to detail::less.

  • Proj1 – The type of an optional projection function for the input range. This defaults to util::projection_identity.

  • Proj2 – The type of an optional projection function for the output range. This defaults to util::projection_identity.

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

  • rng1 – Refers to the source range.

  • rng2 – Refers to the destination range.

  • comp – comp is a callable object. The return value of the INVOKE operation applied to an object of type Comp, when contextually converted to bool, yields true if the first argument of the call is less than the second, and false otherwise. It is assumed that comp will not apply any non-constant function through the dereferenced iterator. This defaults to detail::less.

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

  • proj2 – Specifies the function (or function object) which will be invoked for each pair of elements as a projection operation after the actual predicate comp is invoked.

Returns

The partial_sort_copy algorithm returns a hpx::future<partial_sort_copy_result< range_iterator_t<Rng1>, range_iterator_t<Rng2>>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns partial_sort_copy_result<range_iterator_t<Rng1>, range_iterator_t<Rng2>> otherwise. The algorithm returns {last, result_first + N}.