thrust::discard_iterator#
-
template<typename System = use_default>
class discard_iterator : public thrust::iterator_adaptor<discard_iterator<use_default>, base_iterator, value_type, iterator_system_t<base_iterator>, iterator_traversal_t<base_iterator>, reference># 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 one of the output ranges of reduce_by_key#include <thrust/iterator/discard_iterator.h> #include <thrust/reduce.h> #include <thrust/device_vector.h> int main() { thrust::device_vector<int> keys{1, 3, 3, 3, 2, 2, 1}; thrust::device_vector<int> values{9, 8, 7, 6, 5, 4, 3}; thrust::device_vector<int> result(4); // 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(), thrust::make_discard_iterator(), result.begin()); // result is now [9, 21, 9, 3] return 0; }
See also
Public Types
-
using base_type = Base#
The type of iterator this
iterator_adaptor's
adapts
.
Public Functions
-
inline Base const &base() const#
- Returns:
A
const
reference to theBase
iterator thisiterator_adaptor
adapts.
-
using base_type = Base#