Practice Project
 All Classes Functions Pages
main.cc
1 #include <Particle.h>
2 #include <Pion.h>
3 
4 #include <iostream>
5 #include <string>
6 #include <vector>
7 #include <map>
8 #include <algorithm>
9 
10 using namespace std;
11 
17 int main()
18 {
19  cout << "Dies ist ein Testprogramm für Collaborative Software Design. " << endl;
20 
22  map<string, vector<string> > decayMap;
23  decayMap["B"] = {"D", "Pion"};
24  decayMap["D"] = {"Kaon", "Pion", "Pion"};
25 
27  vector<Particle> particles;
28  //Reserve enough space, that the container doesn't have to be reallocated at push_back.
29  particles.reserve(20);
30  particles.emplace_back("B");
31 
32  for (auto iter = particles.begin(); iter != particles.end(); iter++) {
33  for (auto & name : decayMap[(*iter).getName()]) {
34  particles.emplace_back(name);
35  (*iter).addDaughter(particles.back());
36  }
37  }
38 
39  //Is the number of B daughters equal the number of total particles?
40  cout << "Wir haben so viele Teilchen in unserem Baum: " << particles.size() << endl;
41  cout << "Die Zahl der B Töchter ist: " << particles[0].getNDaughters() << endl;
42 
43  //How many Pions are in the list?
44  cout << "Die Zahl der Pionen ist: "
45  << count(particles.begin(), particles.end(), s_pion)
46  << endl;
47 }