rocPRIM
Public Types | Public Member Functions | Friends | List of all members
transform_iterator< InputIterator, UnaryFunction, ValueType > Class Template Reference

A random-access input (read-only) iterator adaptor for transforming dereferenced values. More...

#include <transform_iterator.hpp>

Public Types

using value_type = ValueType
 The type of the value that can be obtained by dereferencing the iterator.
 
using reference = const value_type &
 A reference type of the type iterated over (value_type). More...
 
using pointer = const value_type *
 A pointer type of the type iterated over (value_type). More...
 
using difference_type = typename std::iterator_traits< InputIterator >::difference_type
 A type used for identify distance between iterators.
 
using iterator_category = std::random_access_iterator_tag
 The category of the iterator.
 
using unary_function = UnaryFunction
 The type of unary function used to transform input range.
 
using self_type = transform_iterator
 

Public Member Functions

ROCPRIM_HOST_DEVICE transform_iterator (InputIterator iterator, UnaryFunction transform)
 Creates a new transform_iterator. More...
 
ROCPRIM_HOST_DEVICE transform_iteratoroperator++ ()
 
ROCPRIM_HOST_DEVICE transform_iterator operator++ (int)
 
ROCPRIM_HOST_DEVICE transform_iteratoroperator-- ()
 
ROCPRIM_HOST_DEVICE transform_iterator operator-- (int)
 
ROCPRIM_HOST_DEVICE value_type operator* () const
 
ROCPRIM_HOST_DEVICE pointer operator-> () const
 
ROCPRIM_HOST_DEVICE value_type operator[] (difference_type distance) const
 
ROCPRIM_HOST_DEVICE transform_iterator operator+ (difference_type distance) const
 
ROCPRIM_HOST_DEVICE transform_iteratoroperator+= (difference_type distance)
 
ROCPRIM_HOST_DEVICE transform_iterator operator- (difference_type distance) const
 
ROCPRIM_HOST_DEVICE transform_iteratoroperator-= (difference_type distance)
 
ROCPRIM_HOST_DEVICE difference_type operator- (transform_iterator other) const
 
ROCPRIM_HOST_DEVICE bool operator== (transform_iterator other) const
 
ROCPRIM_HOST_DEVICE bool operator!= (transform_iterator other) const
 
ROCPRIM_HOST_DEVICE bool operator< (transform_iterator other) const
 
ROCPRIM_HOST_DEVICE bool operator<= (transform_iterator other) const
 
ROCPRIM_HOST_DEVICE bool operator> (transform_iterator other) const
 
ROCPRIM_HOST_DEVICE bool operator>= (transform_iterator other) const
 

Friends

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

Detailed Description

template<class InputIterator, class UnaryFunction, class ValueType = typename ::rocprim::detail::invoke_result< UnaryFunction, typename std::iterator_traits<InputIterator>::value_type >::type>
class transform_iterator< InputIterator, UnaryFunction, ValueType >

A random-access input (read-only) iterator adaptor for transforming dereferenced values.

Overview
  • A transform_iterator uses functor of type UnaryFunction to transform value obtained by dereferencing underlying iterator.
  • Using it for simulating a range filled with results of applying functor of type UnaryFunction to another range saves memory capacity and/or bandwidth.
Template Parameters
InputIterator- type of the underlying random-access input iterator. Must be a random-access iterator.
UnaryFunction- type of the transform functor.
ValueType- type of value that can be obtained by dereferencing the iterator. By default it is the return type of UnaryFunction.

Member Typedef Documentation

◆ pointer

template<class InputIterator, class UnaryFunction, class ValueType = typename ::rocprim::detail::invoke_result< UnaryFunction, typename std::iterator_traits<InputIterator>::value_type >::type>
using transform_iterator< InputIterator, UnaryFunction, ValueType >::pointer = const value_type*

A pointer type of the type iterated over (value_type).

It's const since transform_iterator is a read-only iterator.

◆ reference

template<class InputIterator, class UnaryFunction, class ValueType = typename ::rocprim::detail::invoke_result< UnaryFunction, typename std::iterator_traits<InputIterator>::value_type >::type>
using transform_iterator< InputIterator, UnaryFunction, ValueType >::reference = const value_type&

A reference type of the type iterated over (value_type).

It's const since transform_iterator is a read-only iterator.

Constructor & Destructor Documentation

◆ transform_iterator()

template<class InputIterator, class UnaryFunction, class ValueType = typename ::rocprim::detail::invoke_result< UnaryFunction, typename std::iterator_traits<InputIterator>::value_type >::type>
ROCPRIM_HOST_DEVICE transform_iterator< InputIterator, UnaryFunction, ValueType >::transform_iterator ( InputIterator  iterator,
UnaryFunction  transform 
)
inline

Creates a new transform_iterator.

Parameters
iteratorinput iterator to iterate over and transform.
transformunary function used to transform values obtained from range pointed by iterator.

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