thrust::is_sorted_until
Defined in thrust/sort.h
-
template<typename ForwardIterator>
ForwardIterator thrust::is_sorted_until(ForwardIterator first, ForwardIterator last) This version of
is_sorted_until
returns the last iteratori
in[first,last]
for which the range[first,last)
is sorted usingoperator<
. Ifdistance(first,last) < 2
,is_sorted_until
simply returnslast
.The following code snippet demonstrates how to use
is_sorted_until
to find the first position in an array where the data becomes unsorted:#include <thrust/sort.h> ... int A[8] = {0, 1, 2, 3, 0, 1, 2, 3}; int * B = thrust::is_sorted_until(A, A + 8); // B - A is 4 // [A, B) is sorted
See also
is_sorted
See also
sort
See also
sort_by_key
See also
stable_sort
See also
stable_sort_by_key
- Parameters
first – The beginning of the range of interest.
last – The end of the range of interest.
- Template Parameters
ForwardIterator – is a model of Forward Iterator and
ForwardIterator's
value_type
is a model of LessThan Comparable.- Returns
The last iterator in the input range for which it is sorted.