Template Function thrust::minmax_element(ForwardIterator, ForwardIterator)¶
Function Documentation¶
-
template<typename
ForwardIterator
>
thrust::pair<ForwardIterator, ForwardIterator>thrust
::
minmax_element
(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)
whereimin
is the same iterator returned bymin_element
andimax
is the same iterator returned bymax_element
. This function is potentially more efficient than separate calls tomin_element
andmax_element
.#include <thrust/extrema.h> ... int data[6] = {1, 0, 2, 2, 1, 3}; thrust::pair<int *, int *> result = thrust::minmax_element(data, data + 6); // result.first is data + 1 // result.second is data + 5 // *result.first is 0 // *result.second is 3
- Return
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.- Parameters
first
: The beginning of the sequence.last
: The end of the sequence.
- Template Parameters
ForwardIterator
: is a model of Forward Iterator, andForwardIterator's
value_type
is a model of LessThan Comparable.
- See
min_element
- See
max_element
- See
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1840.pdf