thrust::min
Defined in thrust/extrema.h
-
template<typename T, typename BinaryPredicate>
T thrust::min(const T &lhs, const T &rhs, BinaryPredicate comp) This version of
min
returns the smaller of two values, given a comparison operation.
The following code snippet demonstrates how to use
min
to compute the smaller of two key-value objects.#include <thrust/extrema.h> ... struct key_value { int key; int value; }; struct compare_key_value { __host__ __device__ bool operator()(key_value lhs, key_value rhs) { return lhs.key < rhs.key; } }; ... key_value a = {13, 0}; key_value b = { 7, 1); key_value smaller = thrust::min(a, b, compare_key_value()); // smaller is {7, 1}
See also
max
Note
Returns the first argument when the arguments are equivalent.
- Parameters
lhs – The first value to compare.
rhs – The second value to compare.
comp – A comparison operation.
- Template Parameters
T – is convertible to
BinaryPredicate's
first argument type and to its second argument type.BinaryPredicate – is a model of BinaryPredicate.
- Returns
The smaller element.