HPX - High Performance ParalleX

PrevUpHomeNext

Function template minmax_element

hpx::parallel::v1::minmax_element

Synopsis

// In header: <hpx/parallel/algorithms/minmax.hpp>


template<typename ExPolicy, typename FwdIter, typename F> 
  unspecified minmax_element(ExPolicy && policy, FwdIter first, FwdIter last, 
                             F && f);

Description

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

[Note] Note

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

The comparisons in the parallel minmax_element algorithm invoked with an execution policy object of type sequential_execution_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_execution_policy or parallel_task_execution_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.

Parameters:

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 Type2 &b);


The signature does not need to have const &, but the function must not modify the objects passed to it. The types Type1 and Type2 must be such that objects of types InIter1 and InIter2 can be dereferenced and then implicitly converted to Type1 and Type2 respectively

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.

policy

The execution policy to use for the scheduling of the iterations.

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.

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.

FwdIter

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

Returns:

The minmax_element algorithm returns a hpx::future<FwdIter> if the execution policy is of type sequential_task_execution_policy or parallel_task_execution_policy and returns FwdIter otherwise. The minmax_element algorithm returns a pair consisting of an iterator to the smallest element as the first element and an iterator to the greatest element as the second. 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.


PrevUpHomeNext