<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 5, 2013 at 3:21 PM, David van der Spoel <span dir="ltr">&lt;<a href="mailto:spoel@xray.bmc.uu.se" target="_blank">spoel@xray.bmc.uu.se</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">On 2013-02-05 20:59, Roland Schulz wrote:<br>


&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Tue, Feb 5, 2013 at 2:33 PM, Teemu Murtola &lt;<a href="mailto:teemu.murtola@iki.fi">teemu.murtola@iki.fi</a><br>
</div><div class="im">&gt; &lt;mailto:<a href="mailto:teemu.murtola@iki.fi">teemu.murtola@iki.fi</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;             Actually that suggestion is very non-std like. It combines<br>
&gt;             access to the<br>
&gt;             complete range of coordinates ,with the algorithm (copy),<br>
&gt;             and thus is<br>
&gt;             less flexible because these two things can&#39;t be combined<br>
&gt;             differently.<br>
&gt;             So it might be better to provide: &quot;iterator xBegin()&quot; and<br>
&gt;             &quot;iterator<br>
&gt;             xEnd()&quot;. That would allow to copy using:<br>
</div>&gt;             &quot;std::copy(sel.xBegin(),sel.__xEnd(),out)&quot;.<br>
<div><div class="h5">&gt;<br>
&gt;     I think the best way is to provide a method like ConstArrayRef&lt;rvec&gt;<br>
&gt;     positionArray() const, which automatically gives those iterators as<br>
&gt;     well. Haven&#39;t tried this, but this should compile.<br>
&gt;<br>
&gt; That is indeed better. And much simpler. I didn&#39;t realize that the<br>
&gt; positions are stored in gmx_ana_pos_t::x  and that it is contiguous. I<br>
&gt; had assumed that the storage is a structs of positions (x,v,f,x,v,f,<br>
&gt; ..... ) and thus thought it would be more difficult.<br>
&gt;<br>
&gt;     But using std::copy() on a container of rvecs doesn&#39;t work, because<br>
&gt;     rvec is not copyable or assignable. This part still needs work, but<br>
&gt;     is a more general problem than just in the analysis framework.<br>
&gt;<br>
&gt; You&#39;re right. One of the reasons why we need to decide ASAP on a rvec<br>
&gt; replacement/extension.<br>
&gt;<br>
&gt;<br>
&gt;             But I&#39;m not sure we discussed how much we want to make use<br>
&gt;             of iterators.<br>
&gt;             Our modified version changes that mpp uses iterators and we<br>
&gt;             think it got<br>
&gt;             better/more flexible by doing that. I think Teemu tried to<br>
&gt;             avoid them.<br>
&gt;<br>
&gt;<br>
&gt;     You are probably referring to <a href="http://redmine.gromacs.org/issues/856" target="_blank">http://redmine.gromacs.org/issues/856</a>.<br>
&gt;<br>
&gt; Actually I had forgotten about that. I was commenting on the fact that<br>
&gt; you haven&#39;t implemented many custom iterators.<br>
&gt;<br>
&gt;     Overall, iterators are nice (and several classes in the code provide<br>
&gt;     iterator access or take iterators as parameters), but for that<br>
&gt;     particular case would have been tricky to implement (and would still<br>
&gt;     not have strictly fulfilled the strict requirements for an<br>
&gt;     iterator). Also, I&#39;m using iterators extensively for loopring over<br>
&gt;     containers.<br>
&gt;<br>
&gt;<br>
&gt;         Iterators are not mentioned at all on<br>
</div></div>&gt;         <a href="http://www.gromacs.org/index.__php?title=Developer_Zone/__Programming_Guide/Allowed_C%__2B%2B_Features" target="_blank">http://www.gromacs.org/index.__php?title=Developer_Zone/__Programming_Guide/Allowed_C%__2B%2B_Features</a><br>


<div class="im">&gt;         &lt;<a href="http://www.gromacs.org/index.php?title=Developer_Zone/Programming_Guide/Allowed_C%2B%2B_Features" target="_blank">http://www.gromacs.org/index.php?title=Developer_Zone/Programming_Guide/Allowed_C%2B%2B_Features</a>&gt;<br>


&gt;<br>
&gt;<br>
&gt;     It does mention that &quot;do use STL&quot;. ;) And STL uses iterators<br>
&gt;     extensively. I see no reason to limit using iterators defined in<br>
&gt;     STL, nor implementing simple iterators for our custom classes. But<br>
&gt;     creating very complex iterators may not classify as &quot;simple C++&quot;.<br>
&gt;<br>
&gt;<br>
&gt; I agree.<br>
<br>
</div>Looking at <a href="http://www.cplusplus.com/reference/stl/" target="_blank">http://www.cplusplus.com/reference/stl/</a><br>
<br>
To be on the safe side we can/should probably limit ourselves to C++98?<br></blockquote><div style>Yes. Unless can also be made available to C++03/98 (same thing), like shared_ptr and gmx_unique_ptr and is approved.</div>

<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
But is this the same as the example I mentioned using<br>
<br>
std::vector&lt;MyClass&gt;::iterator ?<br></blockquote><div style>Not sure what you mean. <span style="color:rgb(80,0,80)">ConstArrayRef (</span><font color="#500050"><a href="http://jenkins.gromacs.org/job/Doxygen_Gerrit_master/javadoc/html-full/classgmx_1_1ConstArrayRef.html">http://jenkins.gromacs.org/job/Doxygen_Gerrit_master/javadoc/html-full/classgmx_1_1ConstArrayRef.html</a>) is written by Teemu and gives a C++ interface (including iterators) to a standard c array. So it isn&#39;t part of the stl but behaves mostly like a readonly std::vector.</font></div>

<div style><font color="#500050"><br></font></div><div style><font color="#500050">Roland</font></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


<br>
<br>
&gt;<br>
&gt; Roland<br>
&gt;<br>
&gt;<br>
<span class=""><font color="#888888">&gt;<br>
&gt; --<br>
&gt; ORNL/UT Center for Molecular Biophysics <a href="http://cmb.ornl.gov" target="_blank">cmb.ornl.gov</a> &lt;<a href="http://cmb.ornl.gov" target="_blank">http://cmb.ornl.gov</a>&gt;<br>
&gt; <a href="tel:865-241-1537" value="+18652411537">865-241-1537</a> &lt;tel:<a href="tel:865-241-1537" value="+18652411537">865-241-1537</a>&gt;, ORNL PO BOX 2008 MS6309<br>
</font></span><div class="im">&gt;<br>
&gt;<br>
<br>
<br>
--<br>
David van der Spoel, Ph.D., Professor of Biology<br>
Dept. of Cell &amp; Molec. Biol., Uppsala University.<br>
Box 596, 75124 Uppsala, Sweden. Phone:  <a href="tel:%2B46184714205" value="+46184714205">+46184714205</a>.<br>
<a href="mailto:spoel@xray.bmc.uu.se">spoel@xray.bmc.uu.se</a>    <a href="http://folding.bmc.uu.se" target="_blank">http://folding.bmc.uu.se</a><br>
</div><div class=""><div class="h5">--<br>
gmx-developers mailing list<br>
<a href="mailto:gmx-developers@gromacs.org">gmx-developers@gromacs.org</a><br>
<a href="http://lists.gromacs.org/mailman/listinfo/gmx-developers" target="_blank">http://lists.gromacs.org/mailman/listinfo/gmx-developers</a><br>
Please don&#39;t post (un)subscribe requests to the list. Use the<br>
www interface or send it to <a href="mailto:gmx-developers-request@gromacs.org">gmx-developers-request@gromacs.org</a>.<br>
<br>
<br>
<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>ORNL/UT Center for Molecular Biophysics <a href="http://cmb.ornl.gov">cmb.ornl.gov</a><br>865-241-1537, ORNL PO BOX 2008 MS6309
</div></div>