Template Function thrust::sequence(ForwardIterator, ForwardIterator, T, T)¶
Function Documentation¶
-
template<typename
ForwardIterator, typenameT>
voidthrust::sequence(ForwardIterator first, ForwardIterator last, T init, T step) sequencefills the range[first, last)with a sequence of numbers.For each iterator
iin the range[first, last), this version ofsequenceperforms the assignment*i = init + step * (i - first).The following code snippet demonstrates how to use
sequenceto fill a range with a sequence of numbers starting from the value 1 with a step size of 3.- Parameters
first: The beginning of the sequence.last: The end of the sequence.init: The first value of the sequence of numbersstep: The difference between consecutive elements.
- 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.T: is a model of Assignable, andTis convertible toForwardIterator'svalue_type.
#include <thrust/sequence.h> ... const int N = 10; int A[N]; thrust::sequence(A, A + 10, 1, 3); // A is now {1, 4, 7, 10, 13, 16, 19, 22, 25, 28}
- Note
Unlike the similar C++ STL function
std::iota,sequenceoffers no guarantee on order of execution.- See