git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@40 331e1502-861f-0410-8da2-ba01fb791d7f
135 lines
9.9 KiB
HTML
135 lines
9.9 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
|
<title>EO: eoVector.h Source File</title>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
|
</head><body>
|
|
<!-- Generated by Doxygen 1.3.9.1 -->
|
|
<div class="qindex"> <form class="search" action="search.php" method="get">
|
|
<a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="pages.html">Related Pages</a> | <span class="search"><u>S</u>earch for <input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
|
|
<div class="nav">
|
|
<a class="el" href="dir_000000.html">src</a></div>
|
|
<h1>eoVector.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-</span>
|
|
00002
|
|
00003 <span class="comment">//-----------------------------------------------------------------------------</span>
|
|
00004 <span class="comment">// eoVector.h</span>
|
|
00005 <span class="comment">// (c) GeNeura Team, 2000 - EEAAX 1999 - Maarten Keijzer 2000</span>
|
|
00006 <span class="comment">/*</span>
|
|
00007 <span class="comment"> This library is free software; you can redistribute it and/or</span>
|
|
00008 <span class="comment"> modify it under the terms of the GNU Lesser General Public</span>
|
|
00009 <span class="comment"> License as published by the Free Software Foundation; either</span>
|
|
00010 <span class="comment"> version 2 of the License, or (at your option) any later version.</span>
|
|
00011 <span class="comment"></span>
|
|
00012 <span class="comment"> This library is distributed in the hope that it will be useful,</span>
|
|
00013 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
|
00014 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
|
|
00015 <span class="comment"> Lesser General Public License for more details.</span>
|
|
00016 <span class="comment"></span>
|
|
00017 <span class="comment"> You should have received a copy of the GNU Lesser General Public</span>
|
|
00018 <span class="comment"> License along with this library; if not, write to the Free Software</span>
|
|
00019 <span class="comment"> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
|
00020 <span class="comment"></span>
|
|
00021 <span class="comment"> Contact: todos@geneura.ugr.es, http://geneura.ugr.es</span>
|
|
00022 <span class="comment"> Marc.Schoenauer@polytechnique.fr</span>
|
|
00023 <span class="comment"> mak@dhi.dk</span>
|
|
00024 <span class="comment"></span>
|
|
00025 <span class="comment"> CVS Info: $Date: 2005/10/06 17:22:40 $ $Header: /cvsroot/eodev/eo/src/eoVector.h,v 1.17 2005/10/06 17:22:40 kuepper Exp $ $Author: kuepper $</span>
|
|
00026 <span class="comment"></span>
|
|
00027 <span class="comment"> */</span>
|
|
00028 <span class="comment">//-----------------------------------------------------------------------------</span>
|
|
00029
|
|
00030 <span class="preprocessor">#ifndef _eoVector_h</span>
|
|
00031 <span class="preprocessor"></span><span class="preprocessor">#define _eoVector_h</span>
|
|
00032 <span class="preprocessor"></span>
|
|
00033 <span class="preprocessor">#include <vector></span>
|
|
00034 <span class="preprocessor">#include <iterator></span>
|
|
00035 <span class="preprocessor">#include <EO.h></span>
|
|
00036
|
|
00045 <span class="keyword">template</span> <<span class="keyword">class</span> FitT, <span class="keyword">class</span> GeneType>
|
|
<a name="l00046"></a><a class="code" href="classeo_vector.html">00046</a> <span class="keyword">class </span><a class="code" href="classeo_vector.html">eoVector</a> : <span class="keyword">public</span> <a class="code" href="class_e_o.html">EO</a><FitT>, <span class="keyword">public</span> std::vector<GeneType>
|
|
00047 {
|
|
00048 <span class="keyword">public</span>:
|
|
00049
|
|
00050 <span class="keyword">using</span> <a class="code" href="class_e_o.html">EO<FitT></a>::invalidate;
|
|
00051 <span class="keyword">using</span> std::vector<GeneType>::operator[];
|
|
00052 <span class="keyword">using</span> std::vector<GeneType>::begin;
|
|
00053 <span class="keyword">using</span> std::vector<GeneType>::end;
|
|
00054 <span class="keyword">using</span> std::vector<GeneType>::resize;
|
|
00055 <span class="keyword">using</span> std::vector<GeneType>::size;
|
|
00056
|
|
00057 <span class="keyword">typedef</span> GeneType AtomType;
|
|
00058 <span class="keyword">typedef</span> std::vector<GeneType> ContainerType;
|
|
00059
|
|
<a name="l00065"></a><a class="code" href="classeo_vector.html#a0">00065</a> <a class="code" href="classeo_vector.html#a0">eoVector</a>(<span class="keywordtype">unsigned</span> size = 0, GeneType value = GeneType())
|
|
00066 : <a class="code" href="class_e_o.html">EO</a><<a class="code" href="classeo_scalar_fitness.html">FitT</a>>(), std::vector<GeneType>(size, value)
|
|
00067 {}
|
|
00068
|
|
00070 <span class="keyword">template</span> <<span class="keyword">class</span> OtherFitnessType>
|
|
<a name="l00071"></a><a class="code" href="classeo_vector.html#a1">00071</a> <a class="code" href="classeo_vector.html#a0">eoVector</a>(<span class="keyword">const</span> <a class="code" href="classeo_vector.html">eoVector<OtherFitnessType, GeneType></a>& _vec) : std::vector<GeneType>(_vec)
|
|
00072 {}
|
|
00073
|
|
00074 <span class="comment">// we can't have a Ctor from a std::vector, it would create ambiguity</span>
|
|
00075 <span class="comment">// with the copy Ctor</span>
|
|
00076 <span class="keywordtype">void</span> value(<span class="keyword">const</span> std::vector<GeneType>& _v)
|
|
00077 {
|
|
00078 <span class="keywordflow">if</span> (_v.size() != size()) <span class="comment">// safety check</span>
|
|
00079 {
|
|
00080 <span class="keywordflow">if</span> (size()) <span class="comment">// NOT an initial empty std::vector</span>
|
|
00081 std::cout << <span class="stringliteral">"Warning: Changing size in eoVector assignation"</span><<std::endl;
|
|
00082 resize(_v.size());
|
|
00083 }
|
|
00084
|
|
00085 std::copy(_v.begin(), _v.end(), begin());
|
|
00086 invalidate();
|
|
00087 }
|
|
00088
|
|
<a name="l00090"></a><a class="code" href="classeo_vector.html#a3">00090</a> <span class="keywordtype">bool</span> operator<(const eoVector<FitT, GeneType>& _eo) <span class="keyword">const</span>
|
|
00091 {
|
|
00092 <span class="keywordflow">return</span> <a class="code" href="class_e_o.html#a6">EO<FitT>::operator<</a>(_eo);
|
|
00093 }
|
|
00094
|
|
<a name="l00096"></a><a class="code" href="classeo_vector.html#a4">00096</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classeo_vector.html#a4">printOn</a>(std::ostream& os)<span class="keyword"> const</span>
|
|
00097 <span class="keyword"> </span>{
|
|
00098 <a class="code" href="class_e_o.html#z10_2">EO<FitT>::printOn</a>(os);
|
|
00099 os << <span class="charliteral">' '</span>;
|
|
00100
|
|
00101 os << size() << <span class="charliteral">' '</span>;
|
|
00102
|
|
00103 std::copy(begin(), end(), std::ostream_iterator<AtomType>(os, <span class="stringliteral">" "</span>));
|
|
00104 }
|
|
00105
|
|
<a name="l00107"></a><a class="code" href="classeo_vector.html#a5">00107</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classeo_vector.html#a5">readFrom</a>(std::istream& is)
|
|
00108 {
|
|
00109 <a class="code" href="class_e_o.html#z10_1">EO<FitT>::readFrom</a>(is);
|
|
00110
|
|
00111 <span class="keywordtype">unsigned</span> sz;
|
|
00112 is >> sz;
|
|
00113
|
|
00114 resize(sz);
|
|
00115 <span class="keywordtype">unsigned</span> i;
|
|
00116
|
|
00117 <span class="keywordflow">for</span> (i = 0; i < sz; ++i)
|
|
00118 {
|
|
00119 AtomType atom;
|
|
00120 is >> atom;
|
|
00121 operator[](i) = atom;
|
|
00122 }
|
|
00123 }
|
|
00124 };
|
|
00125
|
|
00127 <span class="keyword">template</span> <<span class="keyword">class</span> FitT, <span class="keyword">class</span> GeneType>
|
|
00128 <span class="keywordtype">bool</span> operator<(const eoVector<FitT, GeneType>& _eo1, <span class="keyword">const</span> <a class="code" href="classeo_vector.html">eoVector<FitT, GeneType></a>& _eo2)
|
|
00129 {
|
|
00130 <span class="keywordflow">return</span> _eo1.operator<(_eo2);
|
|
00131 }
|
|
00132 <span class="keyword">template</span> <<span class="keyword">class</span> FitT, <span class="keyword">class</span> GeneType>
|
|
00133 <span class="keywordtype">bool</span> operator>(<span class="keyword">const</span> <a class="code" href="classeo_vector.html">eoVector<FitT, GeneType></a>& _eo1, <span class="keyword">const</span> <a class="code" href="classeo_vector.html">eoVector<FitT, GeneType></a>& _eo2)
|
|
00134 {
|
|
00135 <span class="keywordflow">return</span> _eo1.operator>(_eo2);
|
|
00136 }
|
|
00137
|
|
00138 <span class="preprocessor">#endif</span>
|
|
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:39 2006 for EO by
|
|
<a href="http://www.doxygen.org/index.html">
|
|
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.3.9.1 </small></address>
|
|
</body>
|
|
</html>
|