Itoyori  v0.0.1
ityr::count_iterator< T > Class Template Reference

Count iterator. More...

#include <count_iterator.hpp>

Public Types

using difference_type = std::ptrdiff_t
 
using value_type = T
 
using pointer = void
 
using reference = T
 
using iterator_category = std::random_access_iterator_tag
 

Public Member Functions

 count_iterator ()
 
 count_iterator (T val)
 
reference operator* () const
 
reference operator[] (difference_type diff) const
 
this_toperator+= (difference_type diff)
 
this_toperator-= (difference_type diff)
 
this_toperator++ ()
 
this_toperator-- ()
 
this_t operator++ (int)
 
this_t operator-- (int)
 
this_t operator+ (difference_type diff) const
 
this_t operator- (difference_type diff) const
 
difference_type operator- (const this_t &it) const
 

Detailed Description

template<typename T>
class ityr::count_iterator< T >

Count iterator.

A count iterator is a special iterator that has the same dereferenced value as the iterator value.

This is particularly useful when used with iterator-based loop functions (e.g., ityr::for_each()), as it can be used to represent the index of each iteration in the loop.

Example:

ityr::global_vector<int> v = {1, 2, 3, 4, 5};
[](int x, std::size_t i) { std::cout << "v[" << i << "] = " << x << std::endl; });
// Output:
// v[0] = 1
// v[1] = 2
// v[2] = 3
// v[3] = 4
// v[4] = 5
Count iterator.
Definition: count_iterator.hpp:33
Global vector to manage a global memory region.
Definition: global_vector.hpp:129
iterator begin() noexcept
Definition: global_vector.hpp:233
iterator end() noexcept
Definition: global_vector.hpp:234
constexpr read_t read
Read-only checkout mode.
Definition: checkout_span.hpp:19
constexpr sequenced_policy seq
Default serial execution policy for iterator-based loop functions.
Definition: execution.hpp:83
void for_each(const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last, Op op)
Apply an operator to each element in a range.
Definition: parallel_loop.hpp:136
global_iterator< T, Mode > make_global_iterator(ori::global_ptr< T > gptr, Mode)
Make a global iterator to enable/disable automatic checkout.
Definition: global_iterator.hpp:158

Member Typedef Documentation

◆ difference_type

template<typename T >
using ityr::count_iterator< T >::difference_type = std::ptrdiff_t

◆ iterator_category

template<typename T >
using ityr::count_iterator< T >::iterator_category = std::random_access_iterator_tag

◆ pointer

template<typename T >
using ityr::count_iterator< T >::pointer = void

◆ reference

template<typename T >
using ityr::count_iterator< T >::reference = T

◆ value_type

template<typename T >
using ityr::count_iterator< T >::value_type = T

Constructor & Destructor Documentation

◆ count_iterator() [1/2]

template<typename T >
ityr::count_iterator< T >::count_iterator ( )
inline

◆ count_iterator() [2/2]

template<typename T >
ityr::count_iterator< T >::count_iterator ( val)
inline

Member Function Documentation

◆ operator*()

template<typename T >
reference ityr::count_iterator< T >::operator* ( ) const
inline

◆ operator+()

template<typename T >
this_t ityr::count_iterator< T >::operator+ ( difference_type  diff) const
inline

◆ operator++() [1/2]

template<typename T >
this_t& ityr::count_iterator< T >::operator++ ( )
inline

◆ operator++() [2/2]

template<typename T >
this_t ityr::count_iterator< T >::operator++ ( int  )
inline

◆ operator+=()

template<typename T >
this_t& ityr::count_iterator< T >::operator+= ( difference_type  diff)
inline

◆ operator-() [1/2]

template<typename T >
difference_type ityr::count_iterator< T >::operator- ( const this_t it) const
inline

◆ operator-() [2/2]

template<typename T >
this_t ityr::count_iterator< T >::operator- ( difference_type  diff) const
inline

◆ operator--() [1/2]

template<typename T >
this_t& ityr::count_iterator< T >::operator-- ( )
inline

◆ operator--() [2/2]

template<typename T >
this_t ityr::count_iterator< T >::operator-- ( int  )
inline

◆ operator-=()

template<typename T >
this_t& ityr::count_iterator< T >::operator-= ( difference_type  diff)
inline

◆ operator[]()

template<typename T >
reference ityr::count_iterator< T >::operator[] ( difference_type  diff) const
inline

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