new printOn and readFrom functions
(they look more like the eoBit ones)
This commit is contained in:
parent
34d474e6f6
commit
aa0437dc11
1 changed files with 30 additions and 11 deletions
|
|
@ -108,15 +108,12 @@ public :
|
||||||
*/
|
*/
|
||||||
void printOn(std::ostream& os) const
|
void printOn(std::ostream& os) const
|
||||||
{
|
{
|
||||||
|
|
||||||
EO<FType>::printOn(os);
|
EO<FType>::printOn(os);
|
||||||
/*
|
os << ' ';
|
||||||
* old code which caused problems for paradisEO
|
|
||||||
* now we use EO<FType>::readFrom(is)
|
os << size() << ' ';
|
||||||
*
|
|
||||||
os << fitness() << ' ';
|
std::copy(ebegin(), eend(), std::ostream_iterator<Node>(os, " "));
|
||||||
*/
|
|
||||||
std::copy(ebegin(), eend(), ostream_iterator<Node>(os));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -125,20 +122,42 @@ public :
|
||||||
*/
|
*/
|
||||||
void readFrom(std::istream& is)
|
void readFrom(std::istream& is)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
EO<FType>::readFrom(is);
|
EO<FType>::readFrom(is);
|
||||||
|
|
||||||
|
unsigned sz;
|
||||||
|
is >> sz;
|
||||||
|
|
||||||
|
|
||||||
|
vector<Node> v(sz);
|
||||||
|
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
for (i = 0; i < sz; ++i)
|
||||||
|
{
|
||||||
|
Node node;
|
||||||
|
is >> node;
|
||||||
|
v[i] = node;
|
||||||
|
}
|
||||||
|
parse_tree<Node> tmp(v.begin(), v.end());
|
||||||
|
swap(tmp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* old code which caused problems for paradisEO
|
* old code which caused problems for paradisEO
|
||||||
* now we use EO<FType>::readFrom(is)
|
|
||||||
*
|
*
|
||||||
|
* this can be removed once it has proved itself
|
||||||
|
EO<FType>::readFrom(is);
|
||||||
|
|
||||||
|
// even older code
|
||||||
FType fit;
|
FType fit;
|
||||||
is >> fit;
|
is >> fit;
|
||||||
|
|
||||||
fitness(fit);
|
fitness(fit);
|
||||||
*/
|
|
||||||
|
|
||||||
std::copy(istream_iterator<Node>(is), istream_iterator<Node>(), back_inserter(*this));
|
std::copy(istream_iterator<Node>(is), istream_iterator<Node>(), back_inserter(*this));
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Reference in a new issue