UniquePop.cpp
Go to the documentation of this file.00001 #include "UniquePop.h"
00002
00003 #include <iomanip>
00004
00005 using namespace std;
00006
00007 namespace gplib
00008 {
00009
00010 UniquePop::UniquePop()
00011 {
00012 }
00013 UniquePop::~UniquePop()
00014 {
00015 }
00016
00017 bool UniquePop::Insert(const tfitvec &fitness,
00018 const ttranscribed &popmember)
00019 {
00020 pair<tmembermap::iterator, bool> insertresult = MemberHashMap.insert(
00021 std::make_pair(popmember,fitness));
00022 return insertresult.second;
00023 }
00024
00025 bool UniquePop::Find(const ttranscribed &popmember, tfitvec &fitness)
00026 {
00027 tmembermap::iterator FindPos = MemberHashMap.find(popmember);
00028 if (FindPos == MemberHashMap.end())
00029 return false;
00030
00031 fitness = FindPos->second;
00032 return true;
00033
00034 }
00035
00036 void UniquePop::PrintAll(std::ostream &output)
00037 {
00038 tmembermap::iterator outit;
00039
00040 for (outit = MemberHashMap.begin(); outit != MemberHashMap.end(); ++outit)
00041 {
00042 output << setprecision(10);
00043 copy(outit->first.begin(), outit->first.end(), ostream_iterator<
00044 double> (output, " "));
00045 output << " ";
00046 copy(outit->second.begin(), outit->second.end(),
00047 ostream_iterator<double> (output, " "));
00048 output << endl;
00049 }
00050 }
00051 }