thrust
List of all members
thrust::discard_iterator< System > Class Template Reference

#include <thrust/iterator/discard_iterator.h>

Inherits type< System >.

Detailed Description

template<typename System = use_default>
class thrust::discard_iterator< System >

discard_iterator is an iterator which represents a special kind of pointer that ignores values written to it upon dereference. This iterator is useful for ignoring the output of certain algorithms without wasting memory capacity or bandwidth. discard_iterator may also be used to count the size of an algorithm's output which may not be known a priori.

The following code snippet demonstrates how to use discard_iterator to ignore ignore one of the output ranges of reduce_by_key

#include <thrust/reduce.h>
int main()
{
thrust::device_vector<int> keys(7), values(7);
keys[0] = 1;
keys[1] = 3;
keys[2] = 3;
keys[3] = 3;
keys[4] = 2;
keys[5] = 2;
keys[6] = 1;
values[0] = 9;
values[1] = 8;
values[2] = 7;
values[3] = 6;
values[4] = 5;
values[5] = 4;
values[6] = 3;
// we are only interested in the reduced values
// use discard_iterator to ignore the output keys
thrust::reduce_by_key(keys.begin(), keys.end(),
values.begin(),
result.begin());
// result is now [9, 21, 9, 3]
return 0;
}
See also
make_discard_iterator

The documentation for this class was generated from the following file: