thrust::max_element
Defined in thrust/extrema.h
- 
template<typename DerivedPolicy, typename ForwardIterator>
 ForwardIterator thrust::max_element(const thrust::detail::execution_policy_base<DerivedPolicy> &exec, ForwardIterator first, ForwardIterator last)
- max_elementfinds the largest element in the range- [first, last). It returns the first iterator- iin- [first, last)such that no other iterator in- [first, last)points to a value larger than- *i. The return value is- lastif and only if- [first, last)is an empty range.- The two versions of - max_elementdiffer in how they define whether one element is greater than another. This version compares objects using- operator<. Specifically, this version of- max_elementreturns the first iterator- iin- [first, last)such that, for every iterator- jin- [first, last),- *i < *jis- false.- The algorithm’s execution is parallelized as determined by - exec.- #include <thrust/extrema.h> #include <thrust/execution_policy.h> ... int data[6] = {1, 0, 2, 2, 1, 3}; int *result = thrust::max_element(thrust::host, data, data + 6); // *result == 3 - Parameters
- exec – The execution policy to use for parallelization. 
- first – The beginning of the sequence. 
- last – The end of the sequence. 
 
- Template Parameters
- A – Thrust backend system. 
- ForwardIterator – is a model of Forward Iterator, and - ForwardIterator's- value_typeis a model of LessThan Comparable.
 
- Returns
- An iterator pointing to the largest element of the range - [first, last), if it is not an empty range;- last, otherwise.