ATLAS Offline Software
Public Types | Public Member Functions | Private Attributes | Friends | List of all members
CombinationsIterator Class Reference

#include <CombinationsIterator.h>

Collaboration diagram for CombinationsIterator:

Public Types

using iterator_category = std::forward_iterator_tag
 
using difference_type = std::ptrdiff_t
 
using value_type = HypoJetVector
 
using reference = HypoJetVector &
 
using pointer = HypoJetVector *
 

Public Member Functions

 CombinationsIterator (std::size_t k, const HypoJetVector &input_vals, bool end=false)
 
 CombinationsIterator ()
 
reference operator* ()
 
pointer operator-> ()
 
CombinationsIteratoroperator++ ()
 
CombinationsIterator operator++ (int)
 
CombinationsIterator endIter () const
 

Private Attributes

CombinationsGenerator m_gen {0,0}
 
std::size_t m_k {0}
 
HypoJetVector m_input_vals
 
HypoJetVector m_vals
 
bool m_end {false}
 

Friends

std::ostream & operator<< (std::ostream &, const CombinationsIterator &)
 
bool operator== (const CombinationsIterator &a, const CombinationsIterator &b)
 
bool operator!= (const CombinationsIterator &a, const CombinationsIterator &b)
 

Detailed Description

Definition at line 26 of file CombinationsIterator.h.

Member Typedef Documentation

◆ difference_type

using CombinationsIterator::difference_type = std::ptrdiff_t

Definition at line 30 of file CombinationsIterator.h.

◆ iterator_category

using CombinationsIterator::iterator_category = std::forward_iterator_tag

Definition at line 29 of file CombinationsIterator.h.

◆ pointer

Definition at line 33 of file CombinationsIterator.h.

◆ reference

Definition at line 32 of file CombinationsIterator.h.

◆ value_type

Definition at line 31 of file CombinationsIterator.h.

Constructor & Destructor Documentation

◆ CombinationsIterator() [1/2]

CombinationsIterator::CombinationsIterator ( std::size_t  k,
const HypoJetVector input_vals,
bool  end = false 
)

Definition at line 21 of file CombinationsIterator.cxx.

23  :
24  m_gen{CombinationsGenerator(iv.size(), k)},
25  m_k{k},
26  m_input_vals{iv},
27  m_end{end}
28 {
29  auto indices = m_gen.get();
30  std::transform(indices.cbegin(),
31  indices.cend(),
32  std::back_inserter(m_vals),
33  [iv = this->m_input_vals](const auto& ind) {
34  return iv.at(ind);
35  });
36 }

◆ CombinationsIterator() [2/2]

CombinationsIterator::CombinationsIterator ( )
inline

Definition at line 41 of file CombinationsIterator.h.

41 {}

Member Function Documentation

◆ endIter()

CombinationsIterator CombinationsIterator::endIter ( ) const

Definition at line 39 of file CombinationsIterator.cxx.

39  {
40  return CombinationsIterator(m_k, m_input_vals, true);
41 }

◆ operator*()

reference CombinationsIterator::operator* ( )
inline

Definition at line 44 of file CombinationsIterator.h.

44 {return m_vals;}

◆ operator++() [1/2]

CombinationsIterator& CombinationsIterator::operator++ ( )
inline

Definition at line 50 of file CombinationsIterator.h.

50  {
51  m_end = m_gen.bump();
52  auto indices = m_gen.get();
53 
54  // overwrite m_vals according to the combinations indicies
55  std::transform(indices.cbegin(),
56  indices.cend(),
57  m_vals.begin(),
58  [iv = this->m_input_vals](const auto& ind) {
59  return iv.at(ind);
60  });
61 
62  return *this;
63  }

◆ operator++() [2/2]

CombinationsIterator CombinationsIterator::operator++ ( int  )
inline

Definition at line 66 of file CombinationsIterator.h.

66  {
67  CombinationsIterator tmp = *this;
68  ++(*this);
69  return tmp;
70  }

◆ operator->()

pointer CombinationsIterator::operator-> ( )
inline

Definition at line 47 of file CombinationsIterator.h.

47 {return &m_vals;}

Friends And Related Function Documentation

◆ operator!=

Definition at line 88 of file CombinationsIterator.h.

89  {
90  return !(a==b);
91  }

◆ operator<<

std::ostream& operator<< ( std::ostream &  ,
const CombinationsIterator  
)
friend

Definition at line 3 of file CombinationsIterator.cxx.

3  {
4  os << std::boolalpha
5  << " generator: " << iter.m_gen
6  << " end: " << iter.m_end
7  << " input vals: ";
8  for(const auto& hj : iter.m_input_vals) {
9  os << static_cast<const void*>(hj.get()) << '\n';
10  }
11 
12  os << '\n' <<" vals: ";
13 
14  for(const auto& hj : iter.m_vals) {
15  os << static_cast<const void*>(hj.get()) << '\n';
16  }
17 
18  return os;
19 }

◆ operator==

bool operator== ( const CombinationsIterator a,
const CombinationsIterator b 
)
friend

Definition at line 77 of file CombinationsIterator.h.

78  {
79  return a.m_end == b.m_end and
80  a.m_k == b.m_k and
81  a.m_input_vals == b.m_input_vals;
82 
83 
84  }

Member Data Documentation

◆ m_end

bool CombinationsIterator::m_end {false}
private

Definition at line 101 of file CombinationsIterator.h.

◆ m_gen

CombinationsGenerator CombinationsIterator::m_gen {0,0}
private

Definition at line 95 of file CombinationsIterator.h.

◆ m_input_vals

HypoJetVector CombinationsIterator::m_input_vals
private

Definition at line 98 of file CombinationsIterator.h.

◆ m_k

std::size_t CombinationsIterator::m_k {0}
private

Definition at line 96 of file CombinationsIterator.h.

◆ m_vals

HypoJetVector CombinationsIterator::m_vals
private

Definition at line 99 of file CombinationsIterator.h.


The documentation for this class was generated from the following files:
CombinationsIterator::m_k
std::size_t m_k
Definition: CombinationsIterator.h:96
CombinationsIterator::m_end
bool m_end
Definition: CombinationsIterator.h:101
Trk::indices
std::pair< long int, long int > indices
Definition: AlSymMatBase.h:24
CombinationsGenerator
Definition: CombinationsGenerator.h:24
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
CombinationsIterator::m_vals
HypoJetVector m_vals
Definition: CombinationsIterator.h:99
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
CombinationsIterator::CombinationsIterator
CombinationsIterator()
Definition: CombinationsIterator.h:41
CombinationsIterator::m_gen
CombinationsGenerator m_gen
Definition: CombinationsIterator.h:95
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
CombinationsIterator
Definition: CombinationsIterator.h:26
a
TList * a
Definition: liststreamerinfos.cxx:10
CombinationsIterator::m_input_vals
HypoJetVector m_input_vals
Definition: CombinationsIterator.h:98
checkFileSG.ind
list ind
Definition: checkFileSG.py:118
fitman.k
k
Definition: fitman.py:528