📄 eoonemax_complete.html
字号:
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"><html><head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="GENERATOR" content="Mozilla/4.78 [en] (X11; U; Linux 2.4.7-10 i686) [Netscape]"> <title>Templates/eoOneMax_complete.h</title></head><body text="#000000" bgcolor="#C3C2B4" link="#0000EE" vlink="#551A8B" alink="#FF0000"><a href="eoLesson5.html">Back to Lesson 5</a>- <a href="eoTutorial.html">Tutorial main page </a>- <a href="eoTopDown.html">Top-Downpage</a> - <a href="eoBottomUp.html">Bottom-up page</a> - <a href="eoProgramming.html">Programminghints</a> - <font face="Arial,Helvetica"><a href="doc/html/index.html">EOdocumentation</a></font><br><hr WIDTH="100%"><!-- -------------- End of header ------------------ --><!-- ----------------------------------------------- --><center><h1><font color="#FF0000">Templates/eoOneMax_complete.h</font></h1></center>The user-defined code is on <b><font color="#FF6666">pink background</font></b>..Only the the <a href="eoTutorial.html#colors">character colors have theusual meaning</a>.<p><a NAME="start"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE ><tr NOSAVE><td NOSAVE><tt><font color="#993300">/** -*- mode: c++; c-indent-level:4; c++-member-init-indent: 8; comment-column: 35; -*-</font></tt><br><tt><font color="#993300">The above line is usefulin Emacs-like editors</font></tt><br><tt><font color="#993300">*/</font></tt><p><tt><font color="#993300">/*</font></tt><br><tt><font color="#993300">Template for creating a new representationin EO</font></tt><br><tt><font color="#993300">================================================</font></tt><br><tt><font color="#993300">*/</font></tt><p><b><tt><font color="#993300">#ifndef _eoOneMax_h</font></tt></b><br><b><tt><font color="#993300">#define _eoOneMax_h</font></tt></b><br> </td></tr></table><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE ><tr><td><tt><font color="#000000">/** </font></tt><br><tt><font color="#000000">* A simple example class for bitstring (isNOT supposed to be used :-)</font></tt><br><tt><font color="#000000">*/</font></tt></td></tr></table><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE ><tr><td></td></tr></table><a NAME="representation"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE ><tr><td><b><tt><font color="#999900">template< class FitT></font></tt></b><br><b><tt><font color="#999900">class eoOneMax: public EO<FitT> {</font></tt></b><br><b><tt><font color="#999900">public:</font></tt></b><br><tt><font color="#999900"><b> </b> /** Deafult Ctor: nothing tobe done */</font></tt><br><b><tt><font color="#999900"> eoOneMax() {}</font></tt></b><p><b><tt><font color="#999900"> virtual string className() const{ return "eoOneMax"; }</font></tt></b><br> </td></tr></table><a NAME="output"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE ><tr><td><tt><font color="#3366FF"><b> </b> /** printing... */</font></tt><br><b><tt><font color="#3366FF"> void printOn(ostream&_os) const</font></tt></b><br><b><tt><font color="#3366FF"> {</font></tt></b><br><tt><font color="#3366FF"><b> </b>// First write the fitness</font></tt><br><b><tt><font color="#3366FF"> EO<FitT>::printOn(_os);</font></tt></b><br><b><tt><font color="#3366FF"> _os << ' ';</font></tt></b></td></tr></table><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE ><tr><td><b><tt><font color="#3366FF"> _os << b.size() << ' ' ;</font></tt></b><br><b><tt><font color="#3366FF"> for (unsigned i=0; i<b.size(); i++)</font></tt></b><br><b><tt><font color="#3366FF"> _os << b[i] << ' ' ;</font></tt></b></td></tr></table><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE ><tr><td><b><tt><font color="#3366FF"> }</font></tt></b><p><tt><font color="#3366FF"><b> </b> /** reading... </font></tt><br><tt><font color="#3366FF"> * of course, your readFrom mustbe able to read what printOn writes!!!</font></tt><br><tt><font color="#3366FF"> */</font></tt><br><b><tt><font color="#3366FF"> void readFrom(istream& _is)</font></tt></b><br><b><tt><font color="#3366FF"> {</font></tt></b><br><tt><font color="#3366FF"><b> </b> //of course you should read the fitness first!</font></tt><br><b><tt><font color="#3366FF"> EO<FitT>::readFrom(_is);</font></tt></b></td></tr></table><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE ><tr><td><b><tt><font color="#3366FF"> unsigned s;</font></tt></b><br><b><tt><font color="#3366FF"> _is >> s;</font></tt></b><br><b><tt><font color="#3366FF"> b.resize(s);</font></tt></b><br><b><tt><font color="#3366FF"> for (unsignedi=0; i<s; i++)</font></tt></b><br><b><tt><font color="#3366FF"> {</font></tt></b><br><b><tt><font color="#3366FF"> bool bTmp;</font></tt></b><br><b><tt><font color="#3366FF"> _is >> bTmp;</font></tt></b><br><b><tt><font color="#3366FF"> b[i] = bTmp;</font></tt></b><br><b><tt><font color="#3366FF"> } </font></tt></b></td></tr></table><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE ><tr><td><b><tt><font color="#3366FF"> }</font></tt></b></td></tr></table><a NAME="representation"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE ><tr><td></td></tr></table><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE ><tr><td><tt><font color="#999900"><b> </b> // brute setting (we couldalso have defined a Ctor from a vector<bool>)</font></tt><br><b><tt><font color="#999900"> void setB(vector<bool> &_b)</font></tt></b><br><b><tt><font color="#999900"> {</font></tt></b><br><b><tt><font color="#999900"> b=_b;</font></tt></b><br><b><tt><font color="#999900"> }</font></tt></b><p><tt><font color="#999900"><b> </b> // brute accessing (we couldalso define operator[] ...)</font></tt><br><b><tt><font color="#999900"> const vector<bool> & B()</font></tt></b><br><b><tt><font color="#999900"> {</font></tt></b><br><b><tt><font color="#999900"> return b;</font></tt></b><br><b><tt><font color="#999900"> }</font></tt></b></td></tr></table><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE ><tr><td><br><tt><font color="#999900"><b>private: </b> //put all data here</font></tt></td></tr></table><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE ><tr><td><b><tt><font color="#999900"> std::vector<bool> b;</font></tt></b></td></tr></table><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE ><tr><td><b><tt><font color="#999900">};</font></tt></b><p><b><tt><font color="#999900">#endif</font></tt></b></td></tr></table><hr WIDTH="100%"><a href="eoLesson5.html">Back to Lesson 5</a> - <a href="eoTutorial.html">Tutorialmain page </a>- <a href="eoTopDown.html">Top-Down page</a> - <a href="eoBottomUp.html">Bottom-uppage</a> - <a href="eoProgramming.html">Programming hints</a> - <font face="Arial,Helvetica"><a href="doc/html/index.html">EOdocumentation</a></font><hr><address><a href="mailto:marc.schoenauer@inria.fr">Marc Schoenauer</a></address><br><!-- Created: Nov 2000 --><!-- hhmts start -->Last modified: Sat May4 06:02:46 2002<!-- hhmts end --></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -