thrust

◆ fill() [2/2]

template<typename ForwardIterator , typename T >
__host__ __device__ void thrust::fill ( ForwardIterator  first,
ForwardIterator  last,
const T &  value 
)

fill assigns the value value to every element in the range [first, last). That is, for every iterator i in [first, last), it performs the assignment *i = value.

Parameters
firstThe beginning of the sequence.
lastThe end of the sequence.
valueThe value to be copied.
Template Parameters
ForwardIteratoris a model of Forward Iterator, and ForwardIterator is mutable.
Tis a model of Assignable, and T's value_type is convertible to ForwardIterator's value_type.

The following code snippet demonstrates how to use fill to set a thrust::device_vector's elements to a given value.

#include <thrust/fill.h>
...
thrust::device_vector<int> v(4);
thrust::fill(v.begin(), v.end(), 137);
// v[0] == 137, v[1] == 137, v[2] == 137, v[3] == 137
See also
http://www.sgi.com/tech/stl/fill.html
fill_n
uninitialized_fill