add a typedef + update the use of comparator

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@323 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
liefooga 2007-06-19 07:53:02 +00:00
commit 199f122349

View file

@ -24,13 +24,15 @@
* but it can be replaced at will by any other class that implements the static functions defined therein. * but it can be replaced at will by any other class that implements the static functions defined therein.
* Some static funtions to access to the traits characteristics are re-defined in order not to write a lot of typedef's. * Some static funtions to access to the traits characteristics are re-defined in order not to write a lot of typedef's.
*/ */
template < class ObjectiveVectorTraits, class Type > template < class ObjectiveVectorTraits, class ObjectiveVectorType >
class moeoObjectiveVector : public std::vector < Type > class moeoObjectiveVector : public std::vector < ObjectiveVectorType >
{ {
public: public:
/** The traits of objective vectors */ /** The traits of objective vectors */
typedef ObjectiveVectorTraits Traits; typedef ObjectiveVectorTraits Traits;
/** The type of an objective value */
typedef ObjectiveVectorType Type;
/** /**
@ -123,7 +125,7 @@ public:
bool dominates(const moeoObjectiveVectorDouble < ObjectiveVectorTraits > & _other) const bool dominates(const moeoObjectiveVectorDouble < ObjectiveVectorTraits > & _other) const
{ {
moeoParetoObjectiveVectorComparator < moeoObjectiveVectorDouble<ObjectiveVectorTraits> > comparator; moeoParetoObjectiveVectorComparator < moeoObjectiveVectorDouble<ObjectiveVectorTraits> > comparator;
return comparator(*this, _other); return comparator(_other, *this);
} }
@ -161,21 +163,8 @@ public:
*/ */
bool operator<(const moeoObjectiveVectorDouble < ObjectiveVectorTraits > & _other) const bool operator<(const moeoObjectiveVectorDouble < ObjectiveVectorTraits > & _other) const
{ {
for (unsigned i=0; i < size(); i++) moeoObjectiveObjectiveVectorComparator < moeoObjectiveVectorDouble < ObjectiveVectorTraits > > cmp;
{ return cmp(*this, _other);
if ( fabs(operator[](i) - _other[i]) > ObjectiveVectorTraits::tolerance() )
{
if (operator[](i) < _other[i])
{
return true;
}
else
{
return false;
}
}
}
return false;
} }