rocPRIM
Public Types | Public Member Functions | Friends | List of all members
counting_iterator< Incrementable, Difference > Class Template Reference

A random-access input (read-only) iterator over a sequence of consecutive integer values. More...

#include <counting_iterator.hpp>

Public Types

using value_type = typename std::remove_const< Incrementable >::type
 The type of the value that can be obtained by dereferencing the iterator.
 
using reference = 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 = Difference
 A type used for identify distance between iterators.
 
using iterator_category = std::random_access_iterator_tag
 The category of the iterator.
 
using self_type = counting_iterator
 

Public Member Functions

ROCPRIM_HOST_DEVICE ~counting_iterator ()=default
 Creates counting_iterator with its initial value initialized to its default value (usually 0). More...
 
ROCPRIM_HOST_DEVICE counting_iterator (const value_type value)
 Creates counting_iterator and sets its initial value to value_. More...
 
ROCPRIM_HOST_DEVICE counting_iteratoroperator++ ()
 
ROCPRIM_HOST_DEVICE counting_iterator operator++ (int)
 
ROCPRIM_HOST_DEVICE counting_iteratoroperator-- ()
 
ROCPRIM_HOST_DEVICE counting_iterator operator-- (int)
 
ROCPRIM_HOST_DEVICE value_type operator* () const
 
ROCPRIM_HOST_DEVICE pointer operator-> () const
 
ROCPRIM_HOST_DEVICE counting_iterator operator+ (difference_type distance) const
 
ROCPRIM_HOST_DEVICE counting_iteratoroperator+= (difference_type distance)
 
ROCPRIM_HOST_DEVICE counting_iterator operator- (difference_type distance) const
 
ROCPRIM_HOST_DEVICE counting_iteratoroperator-= (difference_type distance)
 
ROCPRIM_HOST_DEVICE difference_type operator- (counting_iterator other) const
 
ROCPRIM_HOST_DEVICE value_type operator[] (difference_type distance) const
 
ROCPRIM_HOST_DEVICE bool operator== (counting_iterator other) const
 
ROCPRIM_HOST_DEVICE bool operator!= (counting_iterator other) const
 
ROCPRIM_HOST_DEVICE bool operator< (counting_iterator other) const
 
ROCPRIM_HOST_DEVICE bool operator<= (counting_iterator other) const
 
ROCPRIM_HOST_DEVICE bool operator> (counting_iterator other) const
 
ROCPRIM_HOST_DEVICE bool operator>= (counting_iterator other) const
 

Friends

std::ostream & operator<< (std::ostream &os, const counting_iterator &iter)
 

Detailed Description

template<class Incrementable, class Difference = std::ptrdiff_t>
class counting_iterator< Incrementable, Difference >

A random-access input (read-only) iterator over a sequence of consecutive integer values.

Overview
  • A counting_iterator represents a pointer into a range of sequentially increasing values.
  • Using it for simulating a range filled with a sequence of consecutive values saves memory capacity and bandwidth.
Template Parameters
Incrementable- type of value that can be obtained by dereferencing the iterator.
Difference- a type used for identify distance between iterators

Member Typedef Documentation

◆ pointer

template<class Incrementable, class Difference = std::ptrdiff_t>
using counting_iterator< Incrementable, Difference >::pointer = const value_type*

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

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

◆ reference

template<class Incrementable, class Difference = std::ptrdiff_t>
using counting_iterator< Incrementable, Difference >::reference = value_type

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

It's same as value_type since constant_iterator is a read-only iterator and does not have underlying buffer.

Constructor & Destructor Documentation

◆ ~counting_iterator()

template<class Incrementable, class Difference = std::ptrdiff_t>
ROCPRIM_HOST_DEVICE counting_iterator< Incrementable, Difference >::~counting_iterator ( )
inlinedefault

Creates counting_iterator with its initial value initialized to its default value (usually 0).

◆ counting_iterator()

template<class Incrementable, class Difference = std::ptrdiff_t>
ROCPRIM_HOST_DEVICE counting_iterator< Incrementable, Difference >::counting_iterator ( const value_type  value)
inlineexplicit

Creates counting_iterator and sets its initial value to value_.

Parameters
valueinitial value

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