OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
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
A random-access input wrapper for pairing dereferenced values with their corresponding indices (formi...
A key identifier paired with a corresponding value.
Key key
Item key.
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.
 
__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
 

Member Typedef Documentation

◆ difference_type

template<typename InputIteratorT , typename OffsetT = ptrdiff_t, typename OutputValueT = typename std::iterator_traits<InputIteratorT>::value_type>
typedef OffsetT cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::difference_type

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

Definition at line 119 of file arg_index_input_iterator.cuh.

◆ iterator_category

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

The iterator category.

Definition at line 133 of file arg_index_input_iterator.cuh.

◆ pointer

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

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

Definition at line 121 of file arg_index_input_iterator.cuh.

◆ reference

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

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

Definition at line 122 of file arg_index_input_iterator.cuh.

◆ self_type

template<typename InputIteratorT , typename OffsetT = ptrdiff_t, typename OutputValueT = typename std::iterator_traits<InputIteratorT>::value_type>
typedef ArgIndexInputIterator cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::self_type

My own type.

Definition at line 118 of file arg_index_input_iterator.cuh.

◆ value_type

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

The type of the element the iterator can point to.

Definition at line 120 of file arg_index_input_iterator.cuh.

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.

Member Function Documentation

◆ normalize()

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

Normalize.

Definition at line 241 of file arg_index_input_iterator.cuh.

◆ operator!=()

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

Not equal to.

Definition at line 235 of file arg_index_input_iterator.cuh.

◆ operator*()

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

Indirection.

Definition at line 168 of file arg_index_input_iterator.cuh.

◆ operator+()

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

Addition.

Definition at line 178 of file arg_index_input_iterator.cuh.

◆ operator++() [1/2]

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

Prefix increment.

Definition at line 161 of file arg_index_input_iterator.cuh.

◆ operator++() [2/2]

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

Postfix increment.

Definition at line 153 of file arg_index_input_iterator.cuh.

◆ operator+=()

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

Addition assignment.

Definition at line 186 of file arg_index_input_iterator.cuh.

◆ operator-() [1/2]

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

Subtraction.

Definition at line 194 of file arg_index_input_iterator.cuh.

◆ operator-() [2/2]

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

Distance.

Definition at line 209 of file arg_index_input_iterator.cuh.

◆ operator-=()

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

Subtraction assignment.

Definition at line 202 of file arg_index_input_iterator.cuh.

◆ operator->()

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

Structure dereference.

Definition at line 223 of file arg_index_input_iterator.cuh.

◆ operator==()

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

Equal to.

Definition at line 229 of file arg_index_input_iterator.cuh.

◆ operator[]()

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

Array subscript.

Definition at line 216 of file arg_index_input_iterator.cuh.

Friends And Related Symbol Documentation

◆ operator<<

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

ostream operator

Definition at line 248 of file arg_index_input_iterator.cuh.

Field Documentation

◆ itr

template<typename InputIteratorT , typename OffsetT = ptrdiff_t, typename OutputValueT = typename std::iterator_traits<InputIteratorT>::value_type>
InputIteratorT cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::itr
private

Definition at line 138 of file arg_index_input_iterator.cuh.

◆ offset

template<typename InputIteratorT , typename OffsetT = ptrdiff_t, typename OutputValueT = typename std::iterator_traits<InputIteratorT>::value_type>
difference_type cub::ArgIndexInputIterator< InputIteratorT, OffsetT, OutputValueT >::offset
private

Definition at line 139 of file arg_index_input_iterator.cuh.


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