TRIQS/itertools 1.3.0
C++ range library
Loading...
Searching...
No Matches
itertools::prod_iter< EndIters, Iters >

#include <itertools/product.hpp>

Detailed Description

template<typename EndIters, typename... Iters>
struct itertools::prod_iter< EndIters, Iters >

Iterator for a itertools::multiplied (cartesian product) range.

It stores three tuples of iterators of the original ranges:

  • its_begin contains the begin iterators of all ranges
  • its_end contains the end iterators of all ranges
  • its contains the current iterators of all ranges

Incrementing is done from right to left, i.e. the iterator of the last range is incremented first. Once an iterator reaches the end of its range, it is reset to the beginning and the iterator of the previous range is incremented once.

Dereferencing returns a tuple containing the results of dereferencing each iterator.

See itertools::product(Rs &&...rgs) for more details.

Template Parameters
EndItersTuple type containing the end iterators of all ranges.
ItersIterator types.

Definition at line 56 of file product.hpp.

Public Member Functions

 prod_iter ()=default
 Default constructor.
 
 prod_iter (std::tuple< Iters... > its_begin, EndIters its_end)
 Construct a product iterator from given begin iterators and end iterators.
 
decltype(auto) dereference () const
 Dereference the iterator.
 
void increment ()
 Increment the iterator by incrementing the current iterators starting with the iterator of the last range.
 
bool operator== (prod_iter const &other) const
 Equal-to operator for two itertools::prod_iter objects.
 
template<typename SentinelIter >
bool operator== (sentinel_t< SentinelIter > const &s) const
 Equal-to operator for a itertools::prod_iter and an itertools::sentinel_t.
 

Public Attributes

std::tuple< Iters... > its = its_begin
 Tuple containing the current iterators of the original ranges.
 
std::tuple< Iters... > its_begin
 Tuple containing the begin iterators of the original ranges.
 
EndIters its_end
 Tuple containing the end iterators of the original ranges.
 

Static Public Attributes

static constexpr long Rank = sizeof...(Iters)
 Number of original ranges.
 

Constructor & Destructor Documentation

◆ prod_iter()

template<typename EndIters , typename... Iters>
itertools::prod_iter< EndIters, Iters >::prod_iter ( std::tuple< Iters... > its_begin,
EndIters its_end )
inline

Construct a product iterator from given begin iterators and end iterators.

Parameters
its_beginTuple containing begin iterators of the original ranges.
its_endTuple containing end iterators of the original ranges.

Definition at line 78 of file product.hpp.

Member Function Documentation

◆ dereference()

template<typename EndIters , typename... Iters>
decltype(auto) itertools::prod_iter< EndIters, Iters >::dereference ( ) const
inlinenodiscard

Dereference the iterator.

Returns
Tuple containing the dereferenced values of all original iterators.

Definition at line 129 of file product.hpp.

◆ operator==() [1/2]

template<typename EndIters , typename... Iters>
bool itertools::prod_iter< EndIters, Iters >::operator== ( prod_iter< EndIters, Iters > const & other) const
inlinenodiscard

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

Parameters
otheritertools::prod_iter to compare with.
Returns
True, if all original iterators are equal.

Definition at line 105 of file product.hpp.

◆ operator==() [2/2]

template<typename EndIters , typename... Iters>
template<typename SentinelIter >
bool itertools::prod_iter< EndIters, Iters >::operator== ( sentinel_t< SentinelIter > const & s) const
inlinenodiscard

Equal-to operator for a itertools::prod_iter and an itertools::sentinel_t.

We reach the end of the product range, when the first iterator, i.e. std::get<0>(its), is at its end.

Template Parameters
SentinelIterIterator type of the sentinel.
Parameters
sitertools::sentinel_t to compare with.
Returns
True, if the first iterator, i.e. std::get<0>(its), is equal to the iterator of the sentinel.

Definition at line 116 of file product.hpp.


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