ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
HLT::CombinationGenerator Class Reference

#include <Combinators.h>

Collaboration diagram for HLT::CombinationGenerator:

Public Member Functions

 CombinationGenerator (const std::initializer_list< size_t > &collectionSizes)
 construct combnations maker with the sizes of collection to which it should be applied More...
 
void add (size_t nextColl)
 
void reset ()
 
size_t size () const
 
const std::vector< size_t > & operator() () const
 returns current combination More...
 
const std::vector< size_t > & current () const
 
void operator++ ()
 moves to the next combination More...
 
 operator bool () const
 are combinations exhausted More...
 

Private Attributes

std::vector< size_t > m_maxes
 
std::vector< size_t > m_current
 

Detailed Description

Definition at line 18 of file TrigCompositeUtils/TrigCompositeUtils/Combinators.h.

Constructor & Destructor Documentation

◆ CombinationGenerator()

CombinationGenerator::CombinationGenerator ( const std::initializer_list< size_t > &  collectionSizes)

construct combnations maker with the sizes of collection to which it should be applied

Definition at line 12 of file Combinators.cxx.

13  : m_maxes( collectionSizes ),
14  m_current( m_maxes.size() ) {
15  reset();
16 
17 }

Member Function Documentation

◆ add()

void HLT::CombinationGenerator::add ( size_t  nextColl)
inline

Definition at line 24 of file TrigCompositeUtils/TrigCompositeUtils/Combinators.h.

24 { m_maxes.push_back( nextColl ); reset(); }

◆ current()

const std::vector<size_t>& HLT::CombinationGenerator::current ( ) const
inline

Definition at line 31 of file TrigCompositeUtils/TrigCompositeUtils/Combinators.h.

31 { return m_current; }

◆ operator bool()

CombinationGenerator::operator bool ( ) const

are combinations exhausted

Definition at line 52 of file Combinators.cxx.

52  {
53  return not m_current.empty();
54 }

◆ operator()()

const std::vector<size_t>& HLT::CombinationGenerator::operator() ( ) const
inline

returns current combination

Definition at line 30 of file TrigCompositeUtils/TrigCompositeUtils/Combinators.h.

30 { return m_current; }

◆ operator++()

void CombinationGenerator::operator++ ( )

moves to the next combination

Definition at line 29 of file Combinators.cxx.

29  {
30  if ( m_current.empty() ) return;
31  for ( size_t i = 0, imax = m_current.size(); i < imax; ++i ) { // iterate over current indices and find the index which can be increased
32  if ( m_maxes[i] - m_current[i] == 1 ) { // reached end of the range of i-th collection, return to the beginning
33  m_current[i] = 0;
34  } else {
35  m_current[i]++;
36  return;
37  }
38  }
39 
40  // unsuccessful index increase == we need to make op bool returning false and next ++ should not happen
41  m_current.clear();
42 }

◆ reset()

void CombinationGenerator::reset ( )

Definition at line 19 of file Combinators.cxx.

19  {
20  // no combinations when at least one the sizes is 0 ( empty collection )
21  if ( std::any_of( m_maxes.begin(), m_maxes.end(),
22  []( size_t m ){ return m == 0; } ) )
23  m_current.clear();
24  else {
25  fill( m_current.begin(), m_current.end(), 0 );
26  }
27 }

◆ size()

size_t HLT::CombinationGenerator::size ( ) const
inline

Definition at line 26 of file TrigCompositeUtils/TrigCompositeUtils/Combinators.h.

26 { return m_maxes.size(); }

Member Data Documentation

◆ m_current

std::vector<size_t> HLT::CombinationGenerator::m_current
private

◆ m_maxes

std::vector<size_t> HLT::CombinationGenerator::m_maxes
private

The documentation for this class was generated from the following files:
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
lumiFormat.i
int i
Definition: lumiFormat.py:85
HLT::CombinationGenerator::reset
void reset()
Definition: Combinators.cxx:19
imax
int imax(int i, int j)
Definition: TileLaserTimingTool.cxx:33
fill
void fill(H5::Group &out_file, size_t iterations)
Definition: test-hdf5-writer.cxx:95
HLT::CombinationGenerator::m_current
std::vector< size_t > m_current
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:44
HLT::CombinationGenerator::m_maxes
std::vector< size_t > m_maxes
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:43