Init version

This commit is contained in:
2024-10-03 18:43:04 +07:00
commit f80052961f
186 changed files with 71676 additions and 0 deletions

38
individual/Phenotype.cpp Normal file
View File

@@ -0,0 +1,38 @@
#include "Phenotype.h"
#include <iostream>
#include <sstream>
Phenotype::Phenotype(Trait _trait){
this->traitsMap[_trait.getName()] = _trait;
}
void Phenotype::addTrait(Trait _trait){
std::map<std::string,Trait>::iterator it;
it = this->traitsMap.find(_trait.getName());
if(it == this->traitsMap.end()){
this->traitsMap[_trait.getName()] = _trait;
}
else{
std::cerr<<"Phenotype.cpp(16): already has the trait: "<<it->first<<std::endl;
}
}
std::ostream& operator << (std::ostream& os, const Phenotype& p){
std::map<std::string,Trait>::const_iterator it;
for(it = p.traitsMap.begin(); it != p.traitsMap.end(); it++){
os<<(it->first)<<"\t"<<(it->second.getTraitValueCont())<<"\t";
}
return os;
}
std::string Phenotype::toSimpleString() const {
std::stringstream os;
std::map<std::string,Trait>::const_iterator it;
for(it = this->traitsMap.begin(); it != this->traitsMap.end(); it++){
os<<(it->second.getTraitValueCont())<<"\t";
}
return os.str();
}