Template Function thrust::is_sorted_until(ForwardIterator, ForwardIterator)¶
Function Documentation¶
-
template<typename
ForwardIterator>
ForwardIteratorthrust::is_sorted_until(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 following code snippet demonstrates how to use
is_sorted_untilto find the first position in an array where the data becomes unsorted:- Return
The last iterator in the input range for which it is sorted.
- 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 andForwardIterator'svalue_typeis a model of LessThan Comparable.
#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
is_sorted- See
sort- See
sort_by_key- See
stable_sort- See
stable_sort_by_key