StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SearchVector.cc
1 // Author: Lynn Garren
3 // search vectors for a GenParicle* instance
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  if( already_in_vector(v,p) == v->end() ) return true;
14  return false;
15 }
16 
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  std::vector<GenParticle*>::iterator it;
22  for( it = v->begin(); it != v->end(); ++it ) {
23  // bail as soon as we find a match
24  if( (*it) == p ) return it;
25  }
26  return v->end();
27 }
28 
29 } // HepMC
bool not_in_vector(std::vector< HepMC::GenParticle * > *, GenParticle *)
returns true if it cannot find GenParticle* in the vector
Definition: SearchVector.cc:11
std::vector< HepMC::GenParticle * >::iterator already_in_vector(std::vector< HepMC::GenParticle * > *, GenParticle *)
returns true if GenParticle is in the vector
Definition: SearchVector.cc:18
The GenParticle class contains information about generated particles.
Definition: GenParticle.h:60