00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef MOEOBITVECTOR_H_
00014 #define MOEOBITVECTOR_H_
00015
00016 #include <core/moeoVector.h>
00017
00021 template < class MOEOObjectiveVector, class MOEOFitness, class MOEODiversity >
00022 class moeoBitVector : public moeoVector < MOEOObjectiveVector, MOEOFitness, MOEODiversity, bool >
00023 {
00024 public:
00025
00026 using moeoVector < MOEOObjectiveVector, MOEOFitness, MOEODiversity, bool > :: begin;
00027 using moeoVector < MOEOObjectiveVector, MOEOFitness, MOEODiversity, bool > :: end;
00028 using moeoVector < MOEOObjectiveVector, MOEOFitness, MOEODiversity, bool > :: resize;
00029 using moeoVector < MOEOObjectiveVector, MOEOFitness, MOEODiversity, bool > :: size;
00030
00031
00037 moeoBitVector(unsigned int _size = 0, bool _value = false) : moeoVector< MOEOObjectiveVector, MOEOFitness, MOEODiversity, bool >(_size, _value)
00038 {}
00039
00040
00044 virtual std::string className() const
00045 {
00046 return "moeoBitVector";
00047 }
00048
00049
00054 virtual void printOn(std::ostream & _os) const
00055 {
00056 MOEO < MOEOObjectiveVector, MOEOFitness, MOEODiversity >::printOn(_os);
00057 _os << ' ';
00058 _os << size() << ' ';
00059 std::copy(begin(), end(), std::ostream_iterator<bool>(_os));
00060 }
00061
00062
00067 virtual void readFrom(std::istream & _is)
00068 {
00069 MOEO < MOEOObjectiveVector, MOEOFitness, MOEODiversity >::readFrom(_is);
00070 unsigned int s;
00071 _is >> s;
00072 std::string bits;
00073 _is >> bits;
00074 if (_is)
00075 {
00076 resize(bits.size());
00077 std::transform(bits.begin(), bits.end(), begin(), std::bind2nd(std::equal_to<char>(), '1'));
00078 }
00079 }
00080
00081 };
00082
00083 #endif