ATLAS Offline Software
Public Types | Public Member Functions | Private Attributes | List of all members
TrigCompositeUtils::ProductItr< Iterator > Class Template Reference

Iterates over all combinations of the provided input iterators. More...

#include <ProductItr.h>

Collaboration diagram for TrigCompositeUtils::ProductItr< Iterator >:

Public Types

using iterator_category = std::input_iterator_tag
 Iterator traits. More...
 
using value_type = std::vector< Iterator >
 
using reference = const value_type &
 
using pointer = const value_type *
 
using difference_type = std::ptrdiff_t
 

Public Member Functions

 ProductItr ()=default
 Default constructor creates a generic past-the-end iterator. More...
 
 ProductItr (const std::vector< Iterator > &itrs, const std::vector< Iterator > &endItrs)
 Construct the iterator from an input vector of iterators. More...
 
std::size_t nItrs () const
 The number of input iterators. More...
 
void reset ()
 Helper function to reset this iterator to its start position. More...
 
bool exhausted () const
 True if this iterator is past the end. More...
 
reference operator* () const
 Dereference. More...
 
pointer operator-> () const
 
ProductItroperator++ ()
 Pre-increment operator. More...
 
ProductItr operator++ (int)
 Post-increment operator. More...
 
bool operator== (const ProductItr &other) const
 Iterator comparison functions. More...
 
bool operator!= (const ProductItr &other) const
 

Private Attributes

std::vector< Iterator > m_startItrs
 
std::vector< Iterator > m_endItrs
 
std::vector< Iterator > m_currentItrs
 

Detailed Description

template<typename Iterator>
class TrigCompositeUtils::ProductItr< Iterator >

Iterates over all combinations of the provided input iterators.

Template Parameters
IteratorThe type of input iterator

Dereferencing the iterator gives the states of all the input iterators in the current combination.

Combinations are generated such that the last iterator is the most fastly varying.

std::vector<std::size_t> v1{0, 1, 2}; std::vector<std::size_t> v2{0, 1}; ProductItr<std::vector<std::size_t>::const_iterator> itr( {v1.begin(), v2.begin()}, {v1.end(), v2.end()}); for (; !itr.exhausted(); ++itr) { for (std::vector<std::size_t>::const_iterator itr2 ; *itr) std::cout << *itr2 << ", " std::cout << std::endl; }

Will produce 0, 0, 0, 1, 1, 0, 1, 1, 2, 0, 2, 1,

Definition at line 43 of file ProductItr.h.

Member Typedef Documentation

◆ difference_type

template<typename Iterator >
using TrigCompositeUtils::ProductItr< Iterator >::difference_type = std::ptrdiff_t

Definition at line 50 of file ProductItr.h.

◆ iterator_category

template<typename Iterator >
using TrigCompositeUtils::ProductItr< Iterator >::iterator_category = std::input_iterator_tag

Iterator traits.

Definition at line 46 of file ProductItr.h.

◆ pointer

template<typename Iterator >
using TrigCompositeUtils::ProductItr< Iterator >::pointer = const value_type *

Definition at line 49 of file ProductItr.h.

◆ reference

template<typename Iterator >
using TrigCompositeUtils::ProductItr< Iterator >::reference = const value_type &

Definition at line 48 of file ProductItr.h.

◆ value_type

template<typename Iterator >
using TrigCompositeUtils::ProductItr< Iterator >::value_type = std::vector<Iterator>

Definition at line 47 of file ProductItr.h.

Constructor & Destructor Documentation

◆ ProductItr() [1/2]

template<typename Iterator >
TrigCompositeUtils::ProductItr< Iterator >::ProductItr ( )
default

Default constructor creates a generic past-the-end iterator.

◆ ProductItr() [2/2]

template<typename Iterator >
TrigCompositeUtils::ProductItr< Iterator >::ProductItr ( const std::vector< Iterator > &  itrs,
const std::vector< Iterator > &  endItrs 
)

Construct the iterator from an input vector of iterators.

Parameters
itrsThe start positions of the internal iterators
endItrsThe end positions of the internal iterators

Member Function Documentation

◆ exhausted()

template<typename Iterator >
bool TrigCompositeUtils::ProductItr< Iterator >::exhausted ( ) const

True if this iterator is past the end.

◆ nItrs()

template<typename Iterator >
std::size_t TrigCompositeUtils::ProductItr< Iterator >::nItrs ( ) const
inline

The number of input iterators.

Definition at line 64 of file ProductItr.h.

64 { return m_startItrs.size(); }

◆ operator!=()

template<typename Iterator >
bool TrigCompositeUtils::ProductItr< Iterator >::operator!= ( const ProductItr< Iterator > &  other) const

◆ operator*()

template<typename Iterator >
reference TrigCompositeUtils::ProductItr< Iterator >::operator* ( ) const

Dereference.

◆ operator++() [1/2]

template<typename Iterator >
ProductItr& TrigCompositeUtils::ProductItr< Iterator >::operator++ ( )

Pre-increment operator.

◆ operator++() [2/2]

template<typename Iterator >
ProductItr TrigCompositeUtils::ProductItr< Iterator >::operator++ ( int  )

Post-increment operator.

◆ operator->()

template<typename Iterator >
pointer TrigCompositeUtils::ProductItr< Iterator >::operator-> ( ) const

◆ operator==()

template<typename Iterator >
bool TrigCompositeUtils::ProductItr< Iterator >::operator== ( const ProductItr< Iterator > &  other) const

Iterator comparison functions.

◆ reset()

template<typename Iterator >
void TrigCompositeUtils::ProductItr< Iterator >::reset ( )

Helper function to reset this iterator to its start position.

Member Data Documentation

◆ m_currentItrs

template<typename Iterator >
std::vector<Iterator> TrigCompositeUtils::ProductItr< Iterator >::m_currentItrs
private

Definition at line 89 of file ProductItr.h.

◆ m_endItrs

template<typename Iterator >
std::vector<Iterator> TrigCompositeUtils::ProductItr< Iterator >::m_endItrs
private

Definition at line 88 of file ProductItr.h.

◆ m_startItrs

template<typename Iterator >
std::vector<Iterator> TrigCompositeUtils::ProductItr< Iterator >::m_startItrs
private

Definition at line 87 of file ProductItr.h.


The documentation for this class was generated from the following file:
TrigCompositeUtils::ProductItr::m_startItrs
std::vector< Iterator > m_startItrs
Definition: ProductItr.h:87