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

Generator of unique combinations (no indices are repeated) API description. More...

#include <Combinators.h>

Collaboration diagram for HLT::UniqueCombinationGenerator:

Public Member Functions

 UniqueCombinationGenerator (size_t nelems, size_t comblen)
 
void reset ()
 
size_t size () const
 
const std::vector< size_t > & operator() () const
 
const std::vector< size_t > & current () const
 
void operator++ ()
 
 operator bool () const
 

Private Attributes

size_t m_nElements
 
size_t m_combLen
 
std::vector< size_t > m_current
 
std::vector< bool > m_bitmask
 

Detailed Description

Generator of unique combinations (no indices are repeated) API description.

See also
CombinationGenerator

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

Constructor & Destructor Documentation

◆ UniqueCombinationGenerator()

UniqueCombinationGenerator::UniqueCombinationGenerator ( size_t  nelems,
size_t  comblen 
)

Definition at line 44 of file Combinators.cxx.

45  : m_nElements(nelems),
46  m_combLen(comblen),
48  reset();
49  }

Member Function Documentation

◆ current()

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

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

57 { return m_current; }

◆ operator bool()

UniqueCombinationGenerator::operator bool ( ) const

Definition at line 63 of file Combinators.cxx.

63  {
64  return not m_current.empty();
65 }

◆ operator()()

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

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

56 { return current(); }

◆ operator++()

void UniqueCombinationGenerator::operator++ ( )

Definition at line 67 of file Combinators.cxx.

67  {
68  if ( m_current.empty() ) return;
69 
70  const bool exists = std::prev_permutation( m_bitmask.begin(), m_bitmask.end());
71  if ( exists ) {
72  m_current.clear();
73  for (size_t i = 0; i < m_nElements; ++i) {
74  if ( m_bitmask[i] )
75  m_current.push_back(i);
76  }
77  return;
78  }
79  m_current.clear();
80 }

◆ reset()

void UniqueCombinationGenerator::reset ( )

Definition at line 56 of file Combinators.cxx.

56  {
57  m_bitmask.resize(m_combLen, true);
58  m_bitmask.resize(m_nElements, false);
59  m_current.resize(m_combLen);
60  std::iota(m_current.begin(), m_current.end(), 0);
61 }

◆ size()

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

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

55 { return m_combLen; }

Member Data Documentation

◆ m_bitmask

std::vector<bool> HLT::UniqueCombinationGenerator::m_bitmask
private

◆ m_combLen

size_t HLT::UniqueCombinationGenerator::m_combLen
private

◆ m_current

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

◆ m_nElements

size_t HLT::UniqueCombinationGenerator::m_nElements
private

The documentation for this class was generated from the following files:
HLT::UniqueCombinationGenerator::m_nElements
size_t m_nElements
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:62
HLT::UniqueCombinationGenerator::reset
void reset()
Definition: Combinators.cxx:56
HLT::UniqueCombinationGenerator::current
const std::vector< size_t > & current() const
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:57
HLT::UniqueCombinationGenerator::m_current
std::vector< size_t > m_current
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:64
lumiFormat.i
int i
Definition: lumiFormat.py:85
HLT::UniqueCombinationGenerator::m_combLen
size_t m_combLen
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:63
python.dummyaccess.exists
def exists(filename)
Definition: dummyaccess.py:9
HLT::UniqueCombinationGenerator::m_bitmask
std::vector< bool > m_bitmask
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:65