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

Detailed description

template< typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = cub::detail::value_t<InputIteratorT>>
class cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >

A random-access input wrapper for pairing dereferenced values with their corresponding indices (forming KeyValuePair tuples).

Overview
  • ArgIndexInputIteratorTwraps a random access input iterator itr of type InputIteratorT. Dereferencing an ArgIndexInputIteratorTat offset i produces a KeyValuePair value whose key field is i and whose value field is itr[i].
  • Can be used with any data type.
  • Can be constructed, manipulated, and exchanged within and between host and device functions. Wrapped host memory can only be dereferenced on the host, and wrapped device memory can only be dereferenced on the device.
  • Compatible with Thrust API v1.7 or newer.
Snippet
The code snippet below illustrates the use of ArgIndexInputIteratorTto dereference an array of doubles
#include <cub/cub.cuh> // or equivalently <cub/iterator/arg_index_input_iterator.cuh>
// Declare, allocate, and initialize a device array
double *d_in; // e.g., [8.0, 6.0, 7.0, 5.0, 3.0, 0.0, 9.0]
// Create an iterator wrapper
// Within device code:
Tuple item_offset_pair.key = *itr;
printf("%f @ %d\n",
item_offset_pair.value,
item_offset_pair.key); // 8.0 @ 0
itr = itr + 6;
item_offset_pair.key = *itr;
printf("%f @ %d\n",
item_offset_pair.value,
item_offset_pair.key); // 9.0 @ 6
Template Parameters
InputIteratorTThe value type of the wrapped input iterator
OffsetTThe difference type of this iterator (Default: ptrdiff_t)
OutputValueTThe paired value type of the <offset,value> tuple (Default: value type of input iterator)

Public Types

typedef ArgIndexInputIterator self_type
 My own type. More...
 
typedef OffsetT difference_type
 Type to express the result of subtracting one iterator from another. More...
 
typedef KeyValuePair
< difference_type,
OutputValueT > 
value_type
 The type of the element the iterator can point to. More...
 
typedef value_typepointer
 The type of a pointer to an element the iterator can point to. More...
 
typedef value_type 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__ ArgIndexInputIterator (InputIteratorT itr, difference_type offset=0)
 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...
 
__host__ __device__
__forceinline__ void 
normalize ()
 Normalize. More...
 

Friends

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

Member Typedef Documentation

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = cub::detail::value_t<InputIteratorT>>
typedef ArgIndexInputIterator cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::self_type

My own type.

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = cub::detail::value_t<InputIteratorT>>
typedef OffsetT cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::difference_type

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

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = cub::detail::value_t<InputIteratorT>>
typedef KeyValuePair<difference_type, OutputValueT> cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::value_type

The type of the element the iterator can point to.

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = cub::detail::value_t<InputIteratorT>>
typedef value_type* cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::pointer

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

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = cub::detail::value_t<InputIteratorT>>
typedef value_type cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::reference

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

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = cub::detail::value_t<InputIteratorT>>
typedef std::random_access_iterator_tag cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::iterator_category

The iterator category.

Constructor & Destructor Documentation

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = cub::detail::value_t<InputIteratorT>>
__host__ __device__ __forceinline__ cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::ArgIndexInputIterator ( InputIteratorT  itr,
difference_type  offset = 0 
)
inline

Constructor.

Parameters
itrInput iterator to wrap
offsetOffsetT (in items) from itr denoting the position of the iterator

Member Function Documentation

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = cub::detail::value_t<InputIteratorT>>
__host__ __device__ __forceinline__ self_type cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::operator++ ( int  )
inline

Postfix increment.

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = cub::detail::value_t<InputIteratorT>>
__host__ __device__ __forceinline__ self_type cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::operator++ ( )
inline

Prefix increment.

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = cub::detail::value_t<InputIteratorT>>
__host__ __device__ __forceinline__ reference cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::operator* ( ) const
inline

Indirection.

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = cub::detail::value_t<InputIteratorT>>
template<typename Distance >
__host__ __device__ __forceinline__ self_type cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::operator+ ( Distance  n) const
inline

Addition.

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = cub::detail::value_t<InputIteratorT>>
template<typename Distance >
__host__ __device__ __forceinline__ self_type& cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::operator+= ( Distance  n)
inline

Addition assignment.

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = cub::detail::value_t<InputIteratorT>>
template<typename Distance >
__host__ __device__ __forceinline__ self_type cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::operator- ( Distance  n) const
inline

Subtraction.

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = cub::detail::value_t<InputIteratorT>>
template<typename Distance >
__host__ __device__ __forceinline__ self_type& cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::operator-= ( Distance  n)
inline

Subtraction assignment.

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = cub::detail::value_t<InputIteratorT>>
__host__ __device__ __forceinline__ difference_type cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::operator- ( self_type  other) const
inline

Distance.

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = cub::detail::value_t<InputIteratorT>>
template<typename Distance >
__host__ __device__ __forceinline__ reference cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::operator[] ( Distance  n) const
inline

Array subscript.

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = cub::detail::value_t<InputIteratorT>>
__host__ __device__ __forceinline__ pointer cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::operator-> ( )
inline

Structure dereference.

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = cub::detail::value_t<InputIteratorT>>
__host__ __device__ __forceinline__ bool cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::operator== ( const self_type rhs)
inline

Equal to.

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = cub::detail::value_t<InputIteratorT>>
__host__ __device__ __forceinline__ bool cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::operator!= ( const self_type rhs)
inline

Not equal to.

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = cub::detail::value_t<InputIteratorT>>
__host__ __device__ __forceinline__ void cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::normalize ( )
inline

Normalize.

Friends And Related Function Documentation

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = cub::detail::value_t<InputIteratorT>>
std::ostream& operator<< ( std::ostream &  os,
const self_type  
)
friend

ostream operator


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