thrust

◆ sequence() [2/6]

template<typename ForwardIterator >
void thrust::sequence ( ForwardIterator  first,
ForwardIterator  last 
)

sequence fills the range [first, last) with a sequence of numbers.

For each iterator i in the range [first, last), this version of sequence performs the assignment *i = (i - first).

Parameters
firstThe beginning of the sequence.
lastThe end of the sequence.
Template Parameters
ForwardIteratoris a model of Forward Iterator, and ForwardIterator is mutable, and if x and y are objects of ForwardIterator's value_type, then x + y is defined, and if T is ForwardIterator's value_type, then T(0) is defined.

The following code snippet demonstrates how to use sequence to fill a range with a sequence of numbers.

...
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, sequence offers no guarantee on order of execution.
See also
http://www.sgi.com/tech/stl/iota.html