Init version
This commit is contained in:
38
individual/Phenotype.cpp
Normal file
38
individual/Phenotype.cpp
Normal 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();
|
||||
}
|
||||
Reference in New Issue
Block a user