TRIQS/itertools 1.3.0
C++ range library
Loading...
Searching...
No Matches
itertools::stride_iter< Iter >

#include <itertools/stride.hpp>

Detailed Description

template<typename Iter>
struct itertools::stride_iter< Iter >

Iterator for a itertools::strided range.

It stores an iterator of the original range as well as a stride. Incrementing advances the original iterator by the given stride. Dereferencing simply returns the dereferenced original iterator.

See itertools::stride(R &&, std::ptrdiff_t) for more details.

Template Parameters
IterIterator type.

Definition at line 46 of file stride.hpp.

Public Member Functions

 stride_iter ()=default
 Default constructor.
 
 stride_iter (Iter it, std::ptrdiff_t stride)
 Construct a strided iterator from a given iterator and a given stride.
 
decltype(auto) dereference () const
 Dereference the iterator.
 
void increment ()
 Increment the iterator by advancing the original iterator by the stride.
 
bool operator== (stride_iter const &other) const
 Equal-to operator for two itertools::stride_iter objects.
 

Public Attributes

Iter it
 Iterator of the original range.
 
std::ptrdiff_t stride {1}
 Number of elements in the original range to skip when incrementing the iterator.
 

Constructor & Destructor Documentation

◆ stride_iter()

template<typename Iter >
itertools::stride_iter< Iter >::stride_iter ( Iter it,
std::ptrdiff_t stride )
inline

Construct a strided iterator from a given iterator and a given stride.

Parameters
itIterator of the original range.
strideStride for advancing the iterator (has to be > 0).

Definition at line 62 of file stride.hpp.

Member Function Documentation

◆ dereference()

template<typename Iter >
decltype(auto) itertools::stride_iter< Iter >::dereference ( ) const
inlinenodiscard

Dereference the iterator.

Returns
Dereferenced value of the original iterator.

Definition at line 81 of file stride.hpp.

◆ operator==()

template<typename Iter >
bool itertools::stride_iter< Iter >::operator== ( stride_iter< Iter > const & other) const
inlinenodiscard

Equal-to operator for two itertools::stride_iter objects.

Parameters
otheritertools::stride_iter to compare with.
Returns
True, if the original iterators are equal.

Definition at line 75 of file stride.hpp.


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