Jpp
Public Member Functions | Private Attributes | List of all members
JTRIGGER::JModuleCounter Struct Reference

Auxiliary class for counting unique modules. More...

#include <JModuleCounter.hh>

Public Member Functions

 JModuleCounter ()
 Default constructor. More...
 
template<class T >
int operator() (T __begin, T __end) const
 Count unique modules. More...
 

Private Attributes

std::vector< int > buffer
 

Detailed Description

Auxiliary class for counting unique modules.

Definition at line 20 of file JModuleCounter.hh.

Constructor & Destructor Documentation

◆ JModuleCounter()

JTRIGGER::JModuleCounter::JModuleCounter ( )
inline

Default constructor.

Definition at line 24 of file JModuleCounter.hh.

25  {}

Member Function Documentation

◆ operator()()

template<class T >
int JTRIGGER::JModuleCounter::operator() ( __begin,
__end 
) const
inline

Count unique modules.

The template parameter should correspond to a data type which provides for the following method:

       int getModuleID();

Note that the input data are not changed.

Parameters
__beginbegin of data
__endend of data
Returns
number of unique modules

Definition at line 42 of file JModuleCounter.hh.

43  {
44  using namespace std;
45 
46  buffer.resize(distance(__begin, __end));
47 
48  vector<int>::iterator out = buffer.begin();
49 
50  for (T i = __begin; i != __end; ++i, ++out) {
51  *out = i->getModuleID();
52  }
53 
54  sort(buffer.begin(), buffer.end());
55 
56  return distance(buffer.begin(), unique(buffer.begin(), buffer.end()));
57  }

Member Data Documentation

◆ buffer

std::vector<int> JTRIGGER::JModuleCounter::buffer
mutableprivate

Definition at line 60 of file JModuleCounter.hh.


The documentation for this struct was generated from the following file:
std::vector
Definition: JSTDTypes.hh:12
JTRIGGER::JModuleCounter::buffer
std::vector< int > buffer
Definition: JModuleCounter.hh:60
distance
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Definition: PhysicsEvent.hh:434
std
Definition: jaanetDictionary.h:36