ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArBadChannelTool
src
mergeDuplicateEntries.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef mergeDuplicateEntries_H
6
#define mergeDuplicateEntries_H
7
8
#include <vector>
9
18
namespace
LArBadChanImpl
{
19
20
template
<
class
C1,
class
CMP,
class
MERGER>
21
std::vector<typename C1::value_type>
22
mergeDuplicateEntries
(
const
C1& c1,
const
CMP& cmp,
const
MERGER& merger)
23
{
24
typename
C1::const_iterator first = c1.begin();
25
typename
C1::const_iterator current = first;
26
typename
C1::const_iterator last = c1.end();
27
std::vector<typename C1::value_type> result;
28
29
// protection against empty container
30
if
(first == last)
return
result;
31
32
while
(++first != last) {
33
if
(cmp( *current, *first)) {
// elements differ, no need to merge
34
result.push_back(*current);
35
++current;
36
}
37
else
{
// elemens are equivalent, need to merge
38
typename
C1::value_type merged = merger( *current, *first);
39
while
(++first != last && !cmp( *current, *first)) {
40
merged = merger( merged, *first);
// keep merging while elements don't differ
41
}
42
result.push_back(merged);
43
if
(first == last)
return
result;
44
current = first;
// keep track of the element after the last merged
45
}
46
}
47
result.push_back( *current);
48
return
result;
49
}
50
51
struct
DummyMerger
{
52
int
operator()
(
const
int
&
a
,
const
int
&
/*b*/
)
const
{
return
a
;}
53
};
54
55
}
56
57
#endif
a
static Double_t a
Definition
LArPhysWaveHECTool.cxx:38
LArBadChanImpl
A helper class that provides iterators over elements in two separate ordered containers as if the ele...
Definition
combined_ordered_container.h:16
LArBadChanImpl::mergeDuplicateEntries
std::vector< typename C1::value_type > mergeDuplicateEntries(const C1 &c1, const CMP &cmp, const MERGER &merger)
Definition
mergeDuplicateEntries.h:22
LArBadChanImpl::DummyMerger
Definition
mergeDuplicateEntries.h:51
LArBadChanImpl::DummyMerger::operator()
int operator()(const int &a, const int &) const
Definition
mergeDuplicateEntries.h:52
Generated on
for ATLAS Offline Software by
1.17.0