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

#include <itertools/product.hpp>

Detailed Description

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

Iterator for a itertools::multiplied_vec (cartesian product of homogeneous ranges) range.

Similar to itertools::prod_iter, but works with a vector of homogeneous ranges instead of a tuple of heterogeneous ranges. This allows for a runtime-determined number of 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 vector containing the results of dereferencing each iterator.

See itertools::product_vec(std::vector<R> const &) for more details.

Template Parameters
IterIterator type of the ranges.

Definition at line 220 of file product.hpp.

Public Types

using value_type = typename std::iterator_traits<Iter>::value_type
 Value type of the dereferenced iterators.

Public Member Functions

 prod_iter_vec ()=default
 Default constructor.
 prod_iter_vec (std::vector< Iter > its_begin, std::vector< Iter > its_end)
 Construct a product iterator from given begin iterators and end iterators.
std::vector< value_typedereference () 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_vec const &other) const
 Equal-to operator for two itertools::prod_iter_vec objects.
template<typename SentinelIter>
bool operator== (sentinel_t< SentinelIter > const &s) const
 Equal-to operator for a itertools::prod_iter_vec and an itertools::sentinel_t.

Public Attributes

bool done = false
 Flag to track completion for empty product (yields single empty vector).
std::vector< Iter > its
 Vector containing the current iterators of the original ranges.
std::vector< Iter > its_begin
 Vector containing the begin iterators of the original ranges.
std::vector< Iter > its_end
 Vector containing the end iterators of the original ranges.

Constructor & Destructor Documentation

◆ prod_iter_vec()

template<typename Iter>
itertools::prod_iter_vec< Iter >::prod_iter_vec ( std::vector< Iter > its_begin,
std::vector< Iter > its_end )
inline

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

Parameters
its_beginVector containing begin iterators of the original ranges.
its_endVector containing end iterators of the original ranges.

Definition at line 245 of file product.hpp.

Member Function Documentation

◆ dereference()

template<typename Iter>
std::vector< value_type > itertools::prod_iter_vec< Iter >::dereference ( ) const
inlinenodiscard

Dereference the iterator.

Returns
Vector containing the dereferenced values of all original iterators.

Definition at line 289 of file product.hpp.

◆ operator==() [1/2]

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

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

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

Definition at line 268 of file product.hpp.

◆ operator==() [2/2]

template<typename Iter>
template<typename SentinelIter>
bool itertools::prod_iter_vec< Iter >::operator== ( sentinel_t< SentinelIter > const & s) const
inlinenodiscard

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

We reach the end of the product range, when the first iterator, i.e. its[0], is at its end, or when done=true for empty products.

Template Parameters
SentinelIterIterator type of the sentinel.
Parameters
sitertools::sentinel_t to compare with.
Returns
True, if the first iterator, i.e. its[0], is equal to the iterator of the sentinel.

Definition at line 280 of file product.hpp.


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