Verify if the neighbor fitness is invalid or not before the copy of fitness, if it is, the neighbor will copy an invalid fitness else the neighbor fitness will be set with the fitness of the copied neighbor

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2303 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
boufaras 2011-07-08 09:37:32 +00:00
commit 1ab2731502

View file

@ -44,8 +44,7 @@
* Container of the neighbor informations
*/
template<class EOType, class Fitness = typename EOType::Fitness>
class moNeighbor : public EO<Fitness>
{
class moNeighbor: public EO<Fitness> {
public:
typedef EOType EOT;
using EO<Fitness>::fitness;
@ -53,14 +52,19 @@ public:
/**
* Default Constructor
*/
moNeighbor():EO<Fitness>() {}
moNeighbor() :
EO<Fitness> () {
}
/**
* Copy Constructor
* @param _neighbor to copy
*/
moNeighbor(const moNeighbor<EOT, Fitness>& _neighbor) {
if (!(_neighbor.invalid()))
fitness(_neighbor.fitness());
else
(*this).invalidate();
}
/**
@ -68,8 +72,13 @@ public:
* @param _neighbor the neighbor to assign
* @return a neighbor equal to the other
*/
virtual moNeighbor<EOT, Fitness>& operator=(const moNeighbor<EOT, Fitness>& _neighbor) {
virtual moNeighbor<EOT, Fitness>& operator=(
const moNeighbor<EOT, Fitness>& _neighbor) {
if (!(_neighbor.invalid()))
fitness(_neighbor.fitness());
else
(*this).invalidate();
return (*this);
}