OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT > Class Template Reference

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

Detailed Description

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = typename std::iterator_traits<InputIteratorT>::value_type>
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)

Definition at line 113 of file arg_index_input_iterator.cuh.

Public Types

typedef ArgIndexInputIterator self_type
 My own type.
 
typedef OffsetT difference_type
 Type to express the result of subtracting one iterator from another.
 
typedef KeyValuePair< difference_type, OutputValueT > value_type
 The type of the element the iterator can point to.
 
typedef value_typepointer
 The type of a pointer to an element the iterator can point to.
 
typedef value_type reference
 The type of a reference to an element the iterator can point to.
 
typedef std::random_access_iterator_tag iterator_category
 The iterator category.
 

Public Member Functions

__host__ __device__ __forceinline__ ArgIndexInputIterator (InputIteratorT itr, difference_type offset=0)
 Constructor. More...
 
__host__ __device__ __forceinline__ self_type operator++ (int)
 Postfix increment.
 
__host__ __device__ __forceinline__ self_type operator++ ()
 Prefix increment.
 
__host__ __device__ __forceinline__ reference operator * () const
 Indirection.
 
template<typename Distance >
__host__ __device__ __forceinline__ self_type operator+ (Distance n) const
 Addition.
 
template<typename Distance >
__host__ __device__ __forceinline__ self_typeoperator+= (Distance n)
 Addition assignment.
 
template<typename Distance >
__host__ __device__ __forceinline__ self_type operator- (Distance n) const
 Subtraction.
 
template<typename Distance >
__host__ __device__ __forceinline__ self_typeoperator-= (Distance n)
 Subtraction assignment.
 
__host__ __device__ __forceinline__ difference_type operator- (self_type other) const
 Distance.
 
template<typename Distance >
__host__ __device__ __forceinline__ reference operator[] (Distance n) const
 Array subscript.
 
__host__ __device__ __forceinline__ pointer operator-> ()
 Structure dereference.
 
__host__ __device__ __forceinline__ bool operator== (const self_type &rhs)
 Equal to.
 
__host__ __device__ __forceinline__ bool operator!= (const self_type &rhs)
 Not equal to.
 
__host__ __device__ __forceinline__ void normalize ()
 Normalize.
 

Private Attributes

InputIteratorT itr
 
difference_type offset
 

Friends

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

Constructor & Destructor Documentation

◆ ArgIndexInputIterator()

template<typename InputIteratorT, typename OffsetT = ptrdiff_t, typename OutputValueT = typename std::iterator_traits<InputIteratorT>::value_type>
__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

Definition at line 144 of file arg_index_input_iterator.cuh.


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