thrust::is_sorted_until
Defined in thrust/sort.h
-
template<typename DerivedPolicy, typename ForwardIterator>
ForwardIterator thrust::is_sorted_until(const thrust::detail::execution_policy_base<DerivedPolicy> &exec, ForwardIterator first, ForwardIterator last) This version of
is_sorted_untilreturns the last iteratoriin[first,last]for which the range[first,last)is sorted usingoperator<. Ifdistance(first,last) < 2,is_sorted_untilsimply returnslast.The algorithm’s execution is parallelized as determined by
exec.The following code snippet demonstrates how to use
is_sorted_untilto find the first position in an array where the data becomes unsorted using thethrust::hostexecution policy for parallelization:#include <thrust/sort.h> #include <thrust/execution_policy.h> ... int A[8] = {0, 1, 2, 3, 0, 1, 2, 3}; int * B = thrust::is_sorted_until(thrust::host, A, A + 8); // B - A is 4 // [A, B) is sorted
See also
is_sortedSee also
sortSee also
sort_by_keySee also
stable_sortSee also
stable_sort_by_key- Parameters
exec – The execution policy to use for parallelization.
first – The beginning of the range of interest.
last – The end of the range of interest.
- Template Parameters
DerivedPolicy – The name of the derived execution policy.
ForwardIterator – is a model of Forward Iterator and
ForwardIterator'svalue_typeis a model of LessThan Comparable.
- Returns
The last iterator in the input range for which it is sorted.