ATLAS Offline Software
Public Types | Public Member Functions | Private Attributes | List of all members
TrkDriftCircleMath::ResolvedCollection< Data, IsSubset > Class Template Reference

#include <ResolvedCollection.h>

Collaboration diagram for TrkDriftCircleMath::ResolvedCollection< Data, IsSubset >:

Public Types

enum  SubsetState { SubSet = 0, SuperSet = 1, Different = 2 }
 
typedef std::vector< DataDataVec
 

Public Member Functions

const DataVecdata () const
 
DataVecdata ()
 
void clear ()
 
void set (DataVec &data)
 
bool insert (const Data &data)
 

Private Attributes

std::vector< Datam_data {}
 

Detailed Description

template<class Data, class IsSubset>
class TrkDriftCircleMath::ResolvedCollection< Data, IsSubset >

Definition at line 13 of file ResolvedCollection.h.

Member Typedef Documentation

◆ DataVec

template<class Data , class IsSubset >
typedef std::vector<Data> TrkDriftCircleMath::ResolvedCollection< Data, IsSubset >::DataVec

Definition at line 15 of file ResolvedCollection.h.

Member Enumeration Documentation

◆ SubsetState

template<class Data , class IsSubset >
enum TrkDriftCircleMath::ResolvedCollection::SubsetState
Enumerator
SubSet 
SuperSet 
Different 

Definition at line 16 of file ResolvedCollection.h.

16 { SubSet = 0, SuperSet = 1, Different = 2 };

Member Function Documentation

◆ clear()

template<class Data , class IsSubset >
void TrkDriftCircleMath::ResolvedCollection< Data, IsSubset >::clear ( )
inline

Definition at line 22 of file ResolvedCollection.h.

22 { m_data.clear(); }

◆ data() [1/2]

template<class Data , class IsSubset >
DataVec& TrkDriftCircleMath::ResolvedCollection< Data, IsSubset >::data ( )
inline

Definition at line 20 of file ResolvedCollection.h.

20 { return m_data; }

◆ data() [2/2]

template<class Data , class IsSubset >
const DataVec& TrkDriftCircleMath::ResolvedCollection< Data, IsSubset >::data ( ) const
inline

Definition at line 19 of file ResolvedCollection.h.

19 { return m_data; }

◆ insert()

template<class Data , class IsSubset >
bool TrkDriftCircleMath::ResolvedCollection< Data, IsSubset >::insert ( const Data data)
inline

Definition at line 26 of file ResolvedCollection.h.

26  {
27  // add data if collection is empty
28  if (m_data.empty()) {
29  m_data.push_back(data);
30  return true;
31  }
32 
33  IsSubset isSubset;
34 
35  bool inserted(false);
36 
37  // loop over data vector compare new element with existing ones
38  for (unsigned int i = 0; i < m_data.size(); ++i) {
39  // get subset state
40  int state = isSubset(data, m_data[i]);
41 
42 
43  // do nothing in case the new element is a subset of an already inserted element
44  if (state == SubSet) {
45  return false;
46 
47  // if the new element is a super set of an existing on replace it
48  // check all existing elements and keep track of number of replaces
49  } else if (state == SuperSet) {
50  // if not inserted yet replace the subset
51  if (!inserted) {
52  inserted = true;
53  m_data[i] = data;
54  } else {
55  // replace current element with last and restart loop
56  if (i == m_data.size() - 1) {
57  m_data.pop_back();
58  } else {
59  m_data[i] = m_data.back();
60  m_data.pop_back();
61  --i; // here we go back to also check the copied element
62  }
63  }
64  }
65  }
66 
67  // check if new element was SuperSet of existing one
68  if (!inserted) {
69  // insert new element
70  m_data.push_back(data);
71  }
72  return true;
73  }

◆ set()

template<class Data , class IsSubset >
void TrkDriftCircleMath::ResolvedCollection< Data, IsSubset >::set ( DataVec data)
inline

Definition at line 24 of file ResolvedCollection.h.

24 { m_data.swap(data); }

Member Data Documentation

◆ m_data

template<class Data , class IsSubset >
std::vector<Data> TrkDriftCircleMath::ResolvedCollection< Data, IsSubset >::m_data {}
private

Definition at line 76 of file ResolvedCollection.h.


The documentation for this class was generated from the following file:
TrkDriftCircleMath::ResolvedCollection::SuperSet
@ SuperSet
Definition: ResolvedCollection.h:16
TrkDriftCircleMath::ResolvedCollection::SubSet
@ SubSet
Definition: ResolvedCollection.h:16
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrkDriftCircleMath::ResolvedCollection::m_data
std::vector< Data > m_data
Definition: ResolvedCollection.h:76
TrkDriftCircleMath::ResolvedCollection::Different
@ Different
Definition: ResolvedCollection.h:16
TrkDriftCircleMath::ResolvedCollection::data
const DataVec & data() const
Definition: ResolvedCollection.h:19