UniquePop.h
Go to the documentation of this file.00001 #ifndef CUNIQUEPOP_H
00002 #define CUNIQUEPOP_H
00003 #include <boost/unordered_map.hpp>
00004 #include <fstream>
00005 #include "gentypes.h"
00006 namespace gplib
00007 {
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 class UniquePop
00018 {
00019 private:
00020 struct memb_equal
00021 {
00022 bool operator()(ttranscribed const& p1, ttranscribed const& p2) const
00023 {
00024 return std::equal(p1.begin(), p1.end(), p2.begin());
00025 }
00026 };
00027
00028 struct memb_hash: std::unary_function<ttranscribed, std::size_t>
00029 {
00030 std::size_t operator()(ttranscribed const& p) const
00031 {
00032 std::size_t seed = 0;
00033 const size_t length = p.size();
00034 for (size_t i = 0; i < length; ++i)
00035 {
00036 boost::hash_combine(seed, p(i));
00037 }
00038 return seed;
00039 }
00040 };
00041
00042 typedef boost::unordered_map<ttranscribed, tfitvec,memb_hash,memb_equal> tmembermap;
00043 tmembermap MemberHashMap;
00044 public:
00045 bool Find(const ttranscribed &popmember, tfitvec &fitness);
00046 bool Insert(const tfitvec &fitness, const ttranscribed &popmember);
00047 void PrintAll(std::ostream &output);
00048 UniquePop();
00049 virtual ~UniquePop();
00050 };
00051
00052 }
00053 #endif // CUNIQUEPOP_H