CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
CommutativePairs< T > Class Template Reference

#include <CommutativePairs.h>

Public Member Functions

void concatenate (CommutativePairs< T > const &other)
 Add the pairs from another CommutativePairs to this. More...
 
bool contains (T const &a, T const &b) const
 
bool contains (T const &a) const
 
void insert (T const &a, T const &b)
 

Private Attributes

std::vector< std::pair< T, T > > pairs_
 

Detailed Description

template<class T>
class CommutativePairs< T >

Wrapper around std::vector<std::pair<T, T>> when the order of the pair elements is not relevant.

Template Parameters
Tthe type of data stored in the pairs

Definition at line 14 of file CommutativePairs.h.

Member Function Documentation

template<class T>
void CommutativePairs< T >::concatenate ( CommutativePairs< T > const &  other)
inline

Add the pairs from another CommutativePairs to this.

Definition at line 40 of file CommutativePairs.h.

Referenced by PFEGammaAlgo::mergeROsByAnyLink().

40  {
41  pairs_.insert(pairs_.end(), other.pairs_.begin(), other.pairs_.end());
42  }
std::vector< std::pair< T, T > > pairs_
template<class T>
bool CommutativePairs< T >::contains ( T const &  a,
T const &  b 
) const
inline

Definition at line 20 of file CommutativePairs.h.

Referenced by PFEGammaAlgo::calculateEleMVA(), PFEGammaAlgo::unlinkRefinableObjectKFandECALMatchedToHCAL(), and PFEGammaAlgo::unlinkRefinableObjectKFandECALWithBadEoverP().

20  {
21  for (auto const& p : pairs_) {
22  if ((a == p.first && b == p.second) || (b == p.first && a == p.second)) {
23  return true;
24  }
25  }
26  return false;
27  }
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
std::vector< std::pair< T, T > > pairs_
template<class T>
bool CommutativePairs< T >::contains ( T const &  a) const
inline

Definition at line 30 of file CommutativePairs.h.

30  {
31  for (auto const& p : pairs_) {
32  if (a == p.first || a == p.second) {
33  return true;
34  }
35  }
36  return false;
37  }
double a
Definition: hdecay.h:119
std::vector< std::pair< T, T > > pairs_
template<class T>
void CommutativePairs< T >::insert ( T const &  a,
T const &  b 
)
inline

Member Data Documentation

template<class T>
std::vector<std::pair<T, T> > CommutativePairs< T >::pairs_
private