From b70899eb1341441894d24f67a96abf1ab154756a Mon Sep 17 00:00:00 2001 From: liefooga Date: Mon, 14 May 2007 13:29:50 +0000 Subject: [PATCH] more generic representation: moeoObjectiveVector inherits of std::vector git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@293 331e1502-861f-0410-8da2-ba01fb791d7f --- .../src/moeoObjectiveVector.h | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/branches/paradiseo-moeo-1.0/src/moeoObjectiveVector.h b/branches/paradiseo-moeo-1.0/src/moeoObjectiveVector.h index b4b2b78bd..f461f6017 100644 --- a/branches/paradiseo-moeo-1.0/src/moeoObjectiveVector.h +++ b/branches/paradiseo-moeo-1.0/src/moeoObjectiveVector.h @@ -24,8 +24,8 @@ * 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. */ -template < class ObjectiveVectorTraits > -class moeoObjectiveVector +template < class ObjectiveVectorTraits, class Type > +class moeoObjectiveVector : public std::vector < Type > { public: @@ -33,6 +33,21 @@ public: typedef ObjectiveVectorTraits Traits; + /** + * Ctor + */ + moeoObjectiveVector(Type _value = Type()) : std::vector < Type > (ObjectiveVectorTraits::nObjectives(), _value) + {} + + + /** + * Ctor from a vector of Type + * @param _v the std::vector < Type > + */ + moeoObjectiveVector(std::vector < Type > & _v) : std::vector < Type > (_v) + {} + + /** * Parameters setting (for the objective vector of any solution) * @param _nObjectives the number of objectives @@ -78,24 +93,26 @@ public: * i.e. that an objective value is represented using a double, and this for any objective. */ template < class ObjectiveVectorTraits > -class moeoObjectiveVectorDouble : public moeoObjectiveVector < ObjectiveVectorTraits >, public std::vector < double > +class moeoObjectiveVectorDouble : public moeoObjectiveVector < ObjectiveVectorTraits, double > { public: - using std::vector< double >::size; - using std::vector< double >::operator[]; + using moeoObjectiveVector < ObjectiveVectorTraits, double >::size; + using moeoObjectiveVector < ObjectiveVectorTraits, double >::operator[]; /** * Ctor */ - moeoObjectiveVectorDouble() : std::vector < double > (ObjectiveVectorTraits::nObjectives(), 0.0) {} + moeoObjectiveVectorDouble(double _value = 0.0) : moeoObjectiveVector < ObjectiveVectorTraits, double > (_value) + {} /** * Ctor from a vector of doubles * @param _v the std::vector < double > */ - moeoObjectiveVectorDouble(std::vector & _v) : std::vector < double > (_v) {} + moeoObjectiveVectorDouble(std::vector < double > & _v) : moeoObjectiveVector < ObjectiveVectorTraits, double > (_v) + {} /**