GPLIB++
UniquePop.cpp
Go to the documentation of this file.
1 #include "UniquePop.h"
2 
3 #include <iomanip>
4 
5 using namespace std;
6 
7 namespace gplib
8  {
9 
10  UniquePop::UniquePop()
11  {
12  }
13  UniquePop::~UniquePop()
14  {
15  }
16 
17  bool UniquePop::Insert(const tfitvec &fitness,
18  const ttranscribed &popmember)
19  {
20  pair<tmembermap::iterator, bool> insertresult = MemberHashMap.insert(
21  std::make_pair(popmember,fitness));
22  return insertresult.second;
23  }
24 
25  bool UniquePop::Find(const ttranscribed &popmember, tfitvec &fitness)
26  {
27  tmembermap::iterator FindPos = MemberHashMap.find(popmember);
28  if (FindPos == MemberHashMap.end())
29  return false;
30 
31  fitness = FindPos->second;
32  return true;
33 
34  }
35 
36  void UniquePop::PrintAll(std::ostream &output)
37  {
38  tmembermap::iterator outit;
39 
40  for (outit = MemberHashMap.begin(); outit != MemberHashMap.end(); ++outit)
41  {
42  output << setprecision(10);
43  copy(outit->first.begin(), outit->first.end(), ostream_iterator<
44  double> (output, " "));
45  output << " ";
46  copy(outit->second.begin(), outit->second.end(),
47  ostream_iterator<double> (output, " "));
48  output << endl;
49  }
50  }
51  }
ublas::vector< double > ttranscribed
Definition: gentypes.h:21
ublas::vector< double > tfitvec
Definition: gentypes.h:23