hpx/parallel/algorithms/minmax.hpp#

See Public API for a list of names and headers that are part of the public HPX API.

namespace hpx

Functions

template<typename FwdIter, typename F = hpx::parallel::v1::detail::less>
FwdIter min_element(FwdIter first, FwdIter last, F &&f)#

Finds the smallest element in the range [first, last) using the given comparison function f.

The comparisons in the parallel min_element algorithm execute in sequential order in the calling thread.

Note

Complexity: Exactly max(N-1, 0) comparisons, where N = std::distance(first, last).

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

  • F – The type of the function/function object to use (deduced).

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.

  • f – The binary predicate which returns true if the the left argument is less than the right element. The signature of the predicate function should be equivalent to the following:

    bool pred(const Type1 &a, const Type1 &b);
    
    The signature does not need to have const &, but the function must not modify the objects passed to it. The type Type1 must be such that objects of type FwdIter can be dereferenced and then implicitly converted to Type1.

Returns

The min_element algorithm returns FwdIter. The min_element algorithm returns the iterator to the smallest element in the range [first, last). If several elements in the range are equivalent to the smallest element, returns the iterator to the first such element. Returns last if the range is empty.

template<typename ExPolicy, typename FwdIter, typename F = hpx::parallel::v1::detail::less>
hpx::parallel::util::detail::algorithm_result<ExPolicy, FwdIter>::type min_element(ExPolicy &&policy, FwdIter first, FwdIter last, F &&f)#

Finds the smallest element in the range [first, last) using the given comparison function f. Executed according to the policy.

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

The comparisons in the parallel min_element 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: Exactly max(N-1, 0) comparisons, where N = std::distance(first, 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.

  • FwdIter – The type of the source iterators used (deduced). This iterator type must meet the requirements of a forward iterator.

  • F – The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of min_element requires F to meet the requirements of CopyConstructible.

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.

  • f – The binary predicate which returns true if the the left argument is less than the right element. The signature of the predicate function should be equivalent to the following:

    bool pred(const Type1 &a, const Type1 &b);
    
    The signature does not need to have const &, but the function must not modify the objects passed to it. The type Type1 must be such that objects of type FwdIter can be dereferenced and then implicitly converted to Type1.

Returns

The min_element 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 min_element algorithm returns the iterator to the smallest element in the range [first, last). If several elements in the range are equivalent to the smallest element, returns the iterator to the first such element. Returns last if the range is empty.

template<typename FwdIter, typename F = hpx::parallel::v1::detail::less>
FwdIter max_element(FwdIter first, FwdIter last, F &&f)#

Finds the largest element in the range [first, last) using the given comparison function f.

The comparisons in the parallel min_element algorithm execute in sequential order in the calling thread.

Note

Complexity: Exactly max(N-1, 0) comparisons, where N = std::distance(first, last).

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

  • F – The type of the function/function object to use (deduced).

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.

  • f – The binary predicate which returns true if the This argument is optional and defaults to std::less. the left argument is less than the right element. The signature of the predicate function should be equivalent to the following:

    bool pred(const Type1 &a, const Type1 &b);
    
    The signature does not need to have const &, but the function must not modify the objects passed to it. The type Type1 must be such that objects of type FwdIter can be dereferenced and then implicitly converted to Type1.

Returns

The max_element algorithm returns FwdIter. The max_element algorithm returns the iterator to the smallest element in the range [first, last). If several elements in the range are equivalent to the smallest element, returns the iterator to the first such element. Returns last if the range is empty.

template<typename ExPolicy, typename FwdIter, typename F = hpx::parallel::v1::detail::less>
hpx::parallel::util::detail::algorithm_result<ExPolicy, FwdIter>::type max_element(ExPolicy &&policy, FwdIter first, FwdIter last, F &&f)#

Removes all elements satisfying specific criteria from the range Finds the largest element in the range [first, last) using the given comparison function f. Executed according to the policy.

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

The comparisons in the parallel max_element 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: Exactly max(N-1, 0) comparisons, where N = std::distance(first, 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.

  • FwdIter – The type of the source iterators used (deduced). This iterator type must meet the requirements of a forward iterator.

  • F – The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of max_element requires F to meet the requirements of CopyConstructible.

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.

  • f – The binary predicate which returns true if the This argument is optional and defaults to std::less. the left argument is less than the right element. The signature of the predicate function should be equivalent to the following:

    bool pred(const Type1 &a, const Type1 &b);
    
    The signature does not need to have const &, but the function must not modify the objects passed to it. The type Type1 must be such that objects of type FwdIter can be dereferenced and then implicitly converted to Type1.

Returns

The max_element 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 max_element algorithm returns the iterator to the smallest element in the range [first, last). If several elements in the range are equivalent to the smallest element, returns the iterator to the first such element. Returns last if the range is empty.

template<typename FwdIter, typename F = hpx::parallel::v1::detail::less>
minmax_element_result<FwdIter> minmax_element(FwdIter first, FwdIter last, F &&f)#

Finds the largest element in the range [first, last) using the given comparison function f.

The comparisons in the parallel minmax_element algorithm execute in sequential order in the calling thread.

Note

Complexity: At most max(floor(3/2*(N-1)), 0) applications of the predicate, where N = std::distance(first, last).

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

  • F – The type of the function/function object to use (deduced).

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.

  • f – The binary predicate which returns true if the the left argument is less than the right element. This argument is optional and defaults to std::less. The signature of the predicate function should be equivalent to the following:

    bool pred(const Type1 &a, const Type1 &b);
    
    The signature does not need to have const &, but the function must not modify the objects passed to it. The type Type1 must be such that objects of type FwdIter can be dereferenced and then implicitly converted to Type1.

Returns

The minmax_element algorithm returns a minmax_element_result<FwdIter> The minmax_element algorithm returns a pair consisting of an iterator to the smallest element as the min element and an iterator to the largest element as the max element. Returns minmax_element_result<FwdIter>{first,first} if the range is empty. If several elements are equivalent to the smallest element, the iterator to the first such element is returned. If several elements are equivalent to the largest element, the iterator to the last such element is returned.

template<typename ExPolicy, typename FwdIter, typename F = hpx::parallel::v1::detail::less>
hpx::parallel::util::detail::algorithm_result<ExPolicy, minmax_element_result<FwdIter>>::type minmax_element(ExPolicy &&policy, FwdIter first, FwdIter last, F &&f)#

Finds the largest element in the range [first, last) using the given comparison function f.

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

The comparisons in the parallel minmax_element 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 max(floor(3/2*(N-1)), 0) applications of the predicate, where N = std::distance(first, 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.

  • FwdIter – The type of the source iterators used (deduced). This iterator type must meet the requirements of a forward iterator.

  • F – The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of minmax_element requires F to meet the requirements of CopyConstructible.

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.

  • f – The binary predicate which returns true if the the left argument is less than the right element. This argument is optional and defaults to std::less. The signature of the predicate function should be equivalent to the following:

    bool pred(const Type1 &a, const Type1 &b);
    
    The signature does not need to have const &, but the function must not modify the objects passed to it. The type Type1 must be such that objects of type FwdIter can be dereferenced and then implicitly converted to Type1.

Returns

The minmax_element algorithm returns a hpx::future<minmax_element_result<FwdIter>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns minmax_element_result<FwdIter> otherwise. The minmax_element algorithm returns a pair consisting of an iterator to the smallest element as the min element and an iterator to the largest element as the max element. Returns std::make_pair(first,first) if the range is empty. If several elements are equivalent to the smallest element, the iterator to the first such element is returned. If several elements are equivalent to the largest element, the iterator to the last such element is returned.