Line data Source code
1 : //////////////////////////////////////////////////////////////////////////
2 : // Author: Lynn Garren
3 : // search vectors for a GenParicle* instance
4 : //////////////////////////////////////////////////////////////////////////
5 :
6 : #include "HepMC/SearchVector.h"
7 :
8 : namespace HepMC {
9 :
10 :
11 : bool not_in_vector( std::vector<GenParticle*>* v, GenParticle* p )
12 : {
13 0 : if( already_in_vector(v,p) == v->end() ) return true;
14 0 : return false;
15 0 : }
16 :
17 : /// returns true if GenParticle is in the vector
18 : std::vector<HepMC::GenParticle*>::iterator already_in_vector( std::vector<GenParticle*>* v, GenParticle* p )
19 : {
20 : // if the vectors are mostly large, the search should be coded differently
21 0 : std::vector<GenParticle*>::iterator it;
22 0 : for( it = v->begin(); it != v->end(); ++it ) {
23 : // bail as soon as we find a match
24 0 : if( (*it) == p ) return it;
25 : }
26 0 : return v->end();
27 0 : }
28 :
29 : } // HepMC
|