◆ minmax_element() [1/4]

template<typename DerivedPolicy , typename ForwardIterator >
__host__ __device__ thrust::pair<ForwardIterator,ForwardIterator> thrust::minmax_element ( const thrust::detail::execution_policy_base< DerivedPolicy > &  exec,
ForwardIterator  first,
ForwardIterator  last 

minmax_element finds the smallest and largest elements in the range [first, last). It returns a pair of iterators (imin, imax) where imin is the same iterator returned by min_element and imax is the same iterator returned by max_element. This function is potentially more efficient than separate calls to min_element and max_element.

The algorithm's execution is parallelized as determined by exec.

execThe execution policy to use for parallelization.
firstThe beginning of the sequence.
lastThe end of the sequence.
A pair of iterator pointing to the smallest and largest elements of the range [first, last), if it is not an empty range; last, otherwise.
Template Parameters
DerivedPolicyThe name of the derived execution policy.
ForwardIteratoris a model of Forward Iterator, and ForwardIterator's value_type is a model of LessThan Comparable.
#include <thrust/extrema.h>
int data[6] = {1, 0, 2, 2, 1, 3};
// result.first is data + 1
// result.second is data + 5
// *result.first is 0
// *result.second is 3
See also