CUB  
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Methods | Friends | List of all members
cub::CountingInputIterator< ValueType, OffsetT > Class Template Reference

Detailed description

template< typename ValueType, typename OffsetT = ptrdiff_t>
class cub::CountingInputIterator< ValueType, OffsetT >

A random-access input generator for dereferencing a sequence of incrementing integer values.

Overview
  • After initializing a CountingInputIteratorTto a certain integer base, read references at offset will return the value base + offset.
  • Can be constructed, manipulated, dereferenced, and exchanged within and between host and device functions.
  • Compatible with Thrust API v1.7 or newer.
Snippet
The code snippet below illustrates the use of CountingInputIteratorTto dereference a sequence of incrementing integers.
#include <cub/cub.cuh> // or equivalently <cub/iterator/counting_input_iterator.cuh>
printf("%d\n", itr[0]); // 5
printf("%d\n", itr[1]); // 6
printf("%d\n", itr[2]); // 7
printf("%d\n", itr[50]); // 55
Template Parameters
ValueTypeThe value type of this iterator
OffsetTThe difference type of this iterator (Default: ptrdiff_t)

Public Types

typedef CountingInputIterator self_type
 My own type. More...
 
typedef OffsetT difference_type
 Type to express the result of subtracting one iterator from another. More...
 
typedef ValueType value_type
 The type of the element the iterator can point to. More...
 
typedef ValueType * pointer
 The type of a pointer to an element the iterator can point to. More...
 
typedef ValueType reference
 The type of a reference to an element the iterator can point to. More...
 
typedef
std::random_access_iterator_tag 
iterator_category
 The iterator category. More...
 

Public Methods

__host__ __device__ __forceinline__ CountingInputIterator (const ValueType &val)
 Constructor. More...
 
__host__ __device__
__forceinline__ self_type 
operator++ (int)
 Postfix increment. More...
 
__host__ __device__
__forceinline__ self_type 
operator++ ()
 Prefix increment. More...
 
__host__ __device__
__forceinline__ reference 
operator* () const
 Indirection. More...
 
template<typename Distance >
__host__ __device__
__forceinline__ self_type 
operator+ (Distance n) const
 Addition. More...
 
template<typename Distance >
__host__ __device__
__forceinline__ self_type
operator+= (Distance n)
 Addition assignment. More...
 
template<typename Distance >
__host__ __device__
__forceinline__ self_type 
operator- (Distance n) const
 Subtraction. More...
 
template<typename Distance >
__host__ __device__
__forceinline__ self_type
operator-= (Distance n)
 Subtraction assignment. More...
 
__host__ __device__
__forceinline__
difference_type 
operator- (self_type other) const
 Distance. More...
 
template<typename Distance >
__host__ __device__
__forceinline__ reference 
operator[] (Distance n) const
 Array subscript. More...
 
__host__ __device__
__forceinline__ pointer 
operator-> ()
 Structure dereference. More...
 
__host__ __device__
__forceinline__ bool 
operator== (const self_type &rhs)
 Equal to. More...
 
__host__ __device__
__forceinline__ bool 
operator!= (const self_type &rhs)
 Not equal to. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const self_type &itr)
 ostream operator More...
 

Member Typedef Documentation

template<typename ValueType, typename OffsetT = ptrdiff_t>
typedef CountingInputIterator cub::CountingInputIterator< ValueType, OffsetT >::self_type

My own type.

template<typename ValueType, typename OffsetT = ptrdiff_t>
typedef OffsetT cub::CountingInputIterator< ValueType, OffsetT >::difference_type

Type to express the result of subtracting one iterator from another.

template<typename ValueType, typename OffsetT = ptrdiff_t>
typedef ValueType cub::CountingInputIterator< ValueType, OffsetT >::value_type

The type of the element the iterator can point to.

template<typename ValueType, typename OffsetT = ptrdiff_t>
typedef ValueType* cub::CountingInputIterator< ValueType, OffsetT >::pointer

The type of a pointer to an element the iterator can point to.

template<typename ValueType, typename OffsetT = ptrdiff_t>
typedef ValueType cub::CountingInputIterator< ValueType, OffsetT >::reference

The type of a reference to an element the iterator can point to.

template<typename ValueType, typename OffsetT = ptrdiff_t>
typedef std::random_access_iterator_tag cub::CountingInputIterator< ValueType, OffsetT >::iterator_category

The iterator category.

Constructor & Destructor Documentation

template<typename ValueType, typename OffsetT = ptrdiff_t>
__host__ __device__ __forceinline__ cub::CountingInputIterator< ValueType, OffsetT >::CountingInputIterator ( const ValueType &  val)
inline

Constructor.

Parameters
valStarting value for the iterator instance to report

Member Function Documentation

template<typename ValueType, typename OffsetT = ptrdiff_t>
__host__ __device__ __forceinline__ self_type cub::CountingInputIterator< ValueType, OffsetT >::operator++ ( int  )
inline

Postfix increment.

template<typename ValueType, typename OffsetT = ptrdiff_t>
__host__ __device__ __forceinline__ self_type cub::CountingInputIterator< ValueType, OffsetT >::operator++ ( )
inline

Prefix increment.

template<typename ValueType, typename OffsetT = ptrdiff_t>
__host__ __device__ __forceinline__ reference cub::CountingInputIterator< ValueType, OffsetT >::operator* ( ) const
inline

Indirection.

template<typename ValueType, typename OffsetT = ptrdiff_t>
template<typename Distance >
__host__ __device__ __forceinline__ self_type cub::CountingInputIterator< ValueType, OffsetT >::operator+ ( Distance  n) const
inline

Addition.

template<typename ValueType, typename OffsetT = ptrdiff_t>
template<typename Distance >
__host__ __device__ __forceinline__ self_type& cub::CountingInputIterator< ValueType, OffsetT >::operator+= ( Distance  n)
inline

Addition assignment.

template<typename ValueType, typename OffsetT = ptrdiff_t>
template<typename Distance >
__host__ __device__ __forceinline__ self_type cub::CountingInputIterator< ValueType, OffsetT >::operator- ( Distance  n) const
inline

Subtraction.

template<typename ValueType, typename OffsetT = ptrdiff_t>
template<typename Distance >
__host__ __device__ __forceinline__ self_type& cub::CountingInputIterator< ValueType, OffsetT >::operator-= ( Distance  n)
inline

Subtraction assignment.

template<typename ValueType, typename OffsetT = ptrdiff_t>
__host__ __device__ __forceinline__ difference_type cub::CountingInputIterator< ValueType, OffsetT >::operator- ( self_type  other) const
inline

Distance.

template<typename ValueType, typename OffsetT = ptrdiff_t>
template<typename Distance >
__host__ __device__ __forceinline__ reference cub::CountingInputIterator< ValueType, OffsetT >::operator[] ( Distance  n) const
inline

Array subscript.

template<typename ValueType, typename OffsetT = ptrdiff_t>
__host__ __device__ __forceinline__ pointer cub::CountingInputIterator< ValueType, OffsetT >::operator-> ( )
inline

Structure dereference.

template<typename ValueType, typename OffsetT = ptrdiff_t>
__host__ __device__ __forceinline__ bool cub::CountingInputIterator< ValueType, OffsetT >::operator== ( const self_type rhs)
inline

Equal to.

template<typename ValueType, typename OffsetT = ptrdiff_t>
__host__ __device__ __forceinline__ bool cub::CountingInputIterator< ValueType, OffsetT >::operator!= ( const self_type rhs)
inline

Not equal to.

Friends And Related Function Documentation

template<typename ValueType, typename OffsetT = ptrdiff_t>
std::ostream& operator<< ( std::ostream &  os,
const self_type itr 
)
friend

ostream operator


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