Template Function thrust::is_sorted_until(ForwardIterator, ForwardIterator, Compare)¶
Function Documentation¶
-
template<typename
ForwardIterator
, typenameCompare
>
ForwardIteratorthrust
::
is_sorted_until
(ForwardIterator first, ForwardIterator last, Compare comp) This version of
is_sorted_until
returns the last iteratori
in[first,last]
for which the range[first,last)
is sorted using the function objectcomp
. 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 in descending order:- 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.comp
: The function object to use for comparison.
- Template Parameters
ForwardIterator
: is a model of Forward Iterator andForwardIterator's
value_type
is convertible toCompare's
argument_type
.Compare
: is a model of Strict Weak Ordering.
#include <thrust/sort.h> #include <thrust/functional.h> ... int A[8] = {3, 2, 1, 0, 3, 2, 1, 0}; thrust::greater<int> comp; int * B = thrust::is_sorted_until(A, A + 8, comp); // B - A is 4 // [A, B) is sorted in descending order
- See
is_sorted
- See
sort
- See
sort_by_key
- See
stable_sort
- See
stable_sort_by_key