Template Function thrust::sequence(ForwardIterator, ForwardIterator)¶
Function Documentation¶
-
template<typename
ForwardIterator>
voidthrust::sequence(ForwardIterator first, ForwardIterator last) sequencefills the range[first, last)with a sequence of numbers.For each iterator
iin the range[first, last), this version ofsequenceperforms the assignment*i = (i - first).The following code snippet demonstrates how to use
sequenceto fill a range with a sequence of numbers.- Parameters
first: The beginning of the sequence.last: The end of the sequence.
- Template Parameters
ForwardIterator: is a model of Forward Iterator, andForwardIteratoris mutable, and ifxandyare objects ofForwardIterator'svalue_type, thenx + yis defined, and ifTisForwardIterator'svalue_type, thenT(0)is defined.
#include <thrust/sequence.h> ... const int N = 10; int A[N]; thrust::sequence(A, A + 10); // A is now {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
- Note
Unlike the similar C++ STL function
std::iota,sequenceoffers no guarantee on order of execution.- See