Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
CommonTools
UtilAlgos
interface
CollectionFilterTrait.h
Go to the documentation of this file.
1
#ifndef UtilAlgos_CollectionFilterTrait_h
2
#define UtilAlgos_CollectionFilterTrait_h
3
/* \class CollectionFilterTrait<C, S, N>
4
*
5
* \author Luca Lista, INFN
6
*
7
*/
8
#include "
CommonTools/UtilAlgos/interface/AnySelector.h
"
9
#include "
CommonTools/UtilAlgos/interface/MinNumberSelector.h
"
10
11
namespace
helper {
12
13
template
<
typename
C,
typename
S,
typename
N>
14
struct
CollectionFilter
{
15
static
bool
filter
(
const
C
&
source
,
const
S
&
select
,
const
N
& sizeSelect ) {
16
size_t
n
= 0;
17
for
(
typename
C::const_iterator
i
= source.begin();
i
!= source.end(); ++
i
)
18
if
(
select
( *
i
) ) n ++;
19
return
sizeSelect( n );
20
}
21
};
22
23
template
<
typename
C,
typename
S>
24
struct
CollectionFilter
<
C
,
S
,
MinNumberSelector
> {
25
static
bool
filter
(
const
C
&
source
,
const
S
&
select
,
const
MinNumberSelector
& sizeSelect ) {
26
size_t
n
= 0;
27
for
(
typename
C::const_iterator
i
= source.begin();
i
!= source.end(); ++
i
) {
28
if
(
select
( *
i
) ) n ++;
29
if
( sizeSelect( n ) )
return
true
;
30
}
31
return
false
;
32
}
33
};
34
35
template
<
typename
C,
typename
N>
36
struct
CollectionSizeFilter
{
37
template
<
typename
S>
38
static
bool
filter
(
const
C
&
source
,
const
S
& ,
const
N
& sizeSelect ) {
39
return
sizeSelect( source.size() );
40
}
41
};
42
43
template
<
typename
C,
typename
S,
typename
N>
44
struct
CollectionFilterTrait
{
45
typedef
CollectionFilter<C, S, N>
type
;
46
};
47
48
template
<
typename
C,
typename
N>
49
struct
CollectionFilterTrait
<
C
,
AnySelector
,
N
> {
50
typedef
CollectionSizeFilter<C, N>
type
;
51
};
52
53
}
54
55
#endif
56
i
int i
Definition:
DBlmapReader.cc:9
helper::CollectionSizeFilter::filter
static bool filter(const C &source, const S &, const N &sizeSelect)
Definition:
CollectionFilterTrait.h:38
helper::CollectionFilter
Definition:
CollectionFilterTrait.h:14
MinNumberSelector
Definition:
MinNumberSelector.h:10
funct::C
C
Definition:
Factorize.h:141
helper::CollectionFilterTrait
Definition:
CollectionFilterTrait.h:44
helper::CollectionFilterTrait::type
CollectionFilter< C, S, N > type
Definition:
CollectionFilterTrait.h:45
helper::CollectionFilter< C, S, MinNumberSelector >::filter
static bool filter(const C &source, const S &select, const MinNumberSelector &sizeSelect)
Definition:
CollectionFilterTrait.h:25
helper::CollectionFilterTrait< C, AnySelector, N >::type
CollectionSizeFilter< C, N > type
Definition:
CollectionFilterTrait.h:50
helper::CollectionSizeFilter
Definition:
CollectionFilterTrait.h:36
AnySelector.h
N
#define N
Definition:
blowfish.cc:9
S
double S(const TLorentzVector &, const TLorentzVector &)
Definition:
Particle.cc:99
gen::n
int n
Definition:
Cascade2Hadronizer.cc:79
benchmark_cfg.select
tuple select
Definition:
benchmark_cfg.py:25
AnySelector
Definition:
AnySelector.h:10
helper::CollectionFilter::filter
static bool filter(const C &source, const S &select, const N &sizeSelect)
Definition:
CollectionFilterTrait.h:15
source
static std::string const source
Definition:
EdmProvDump.cc:42
MinNumberSelector.h
Generated for CMSSW Reference Manual by
1.8.5