Hi Stephan,<br><br><br><blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
I agree that your version is easier to understand and cleaner to read<br>
but it introduces a runtime check that although being tiny, will slow<br>
down the wrapping of Points and RealPoints slightly.<br></blockquote><br>Thanks for the explanation. But I don&#39;t I buy it. Here is a little test:<br><br>    <a href="https://gist.github.com/2150639">https://gist.github.com/2150639</a><br>

<br>On my system:<br><br>Five trials of RealPointSS yields: 418, 361, 357, 359, 370<br>Five trials of RealPointCR yields: 365, 357, 357, 372, 360<br><br>With each trial consisting of 10 million object creations.<br>
<br>The difference looks negligible to me.<br><br>Regards,<br>Curtis<br><br><br><div class="gmail_quote">On Wed, Mar 21, 2012 at 3:48 AM, Stephan Saalfeld <span dir="ltr">&lt;<a href="mailto:saalfeld@mpi-cbg.de">saalfeld@mpi-cbg.de</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Curtis,<br>
<br>
since I am responsible for that construct, I take the freedom to reply.<br>
<br>
I agree that your version is easier to understand and cleaner to read<br>
but it introduces a runtime check that although being tiny, will slow<br>
down the wrapping of Points and RealPoints slightly.  In situations<br>
where this is happening millions of times, I do not want the additional<br>
cost.  So, I prefer your solution in business code but ImgLib2 aims to<br>
be performance code :).  For clarity, the constructor is protected and<br>
therefore not exposed to the normal API user, a clear Javadoc should<br>
tell extenders about its expected use.  Normally, you will use the<br>
RealPoint.wrap(double[]) factory method instead.  We could make the<br>
constructor private but then we would lose the option to use it from the<br>
now extending classes.<br>
<br>
If this is still too ugly for your gusto, we could make the current<br>
RealPoint and Point AbstractRealPoint and AbstractPoint and introduce<br>
both this constructor and the static wrap method in the extending<br>
RealPoint and Point classes.  I&#39;d actually like that.<br>
<br>
Best,<br>
Stephan<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<br>
On Tue, 2012-03-20 at 23:17 -0500, Curtis Rueden wrote:<br>
&gt; Hi Tobias,<br>
&gt;<br>
&gt; First of all, thanks very much for all the API improvements!<br>
&gt;<br>
&gt; I just have one comment...<br>
&gt;<br>
&gt;                 Why is there the Object x in there?<br>
&gt;<br>
&gt;         If it wouldn&#39;t be there, then the compiler would be unable to<br>
&gt;         distinguish whether you call<br>
&gt;         protected Realpoint( final double[] position )<br>
&gt;         or<br>
&gt;         public RealPoint( final double... position )<br>
&gt;<br>
&gt; Sure, the dummy Object parameter differentiates the constructors.<br>
&gt; However, I do not believe such drastic measures are necessary. Why not<br>
&gt; do something like this instead:<br>
&gt;<br>
&gt;     <a href="https://gist.github.com/2144264" target="_blank">https://gist.github.com/2144264</a><br>
&gt;<br>
&gt; I think it is easier to understand and accomplishes the same ends.<br>
&gt;<br>
&gt; Regards,<br>
&gt; Curtis<br>
&gt;<br>
&gt;<br>
&gt; On Fri, Mar 16, 2012 at 10:18 AM, Tobias Pietzsch<br>
&gt; &lt;<a href="mailto:pietzsch@mpi-cbg.de">pietzsch@mpi-cbg.de</a>&gt; wrote:<br>
&gt;         Hi Steffi,<br>
&gt;<br>
&gt;         thanks a lot for having a look!<br>
&gt;<br>
&gt;<br>
&gt;         On 03/16/2012 03:33 PM, Stephan Preibisch wrote:<br>
&gt;                 I have one question about a protected constructor in<br>
&gt;                 RealPoint though:<br>
&gt;<br>
&gt;                 /**<br>
&gt;                 * Protected constructor that re-uses the passed<br>
&gt;                 position array.<br>
&gt;                 *<br>
&gt;                 * @param position<br>
&gt;                 * array used to store the position.<br>
&gt;                 * @paramx<br>
&gt;                 * unused parameter that changes the method signature<br>
&gt;                 */<br>
&gt;                 protected RealPoint( final double[] position, final<br>
&gt;                 Object x )<br>
&gt;                 {<br>
&gt;                 super( position );<br>
&gt;                 }<br>
&gt;<br>
&gt;                 Why is there the Object x in there?<br>
&gt;<br>
&gt;<br>
&gt;         If it wouldn&#39;t be there, then the compiler would be unable to<br>
&gt;         distinguish whether you call<br>
&gt;         protected Realpoint( final double[] position )<br>
&gt;         or<br>
&gt;         public RealPoint( final double... position )<br>
&gt;<br>
&gt;<br>
&gt;                 Also I have a small question about the CellImg. The<br>
&gt;                 ListImgCells which<br>
&gt;                 holds all cells is typed to DefaultCell, and also<br>
&gt;                 always instantiates<br>
&gt;                 DefaultCells. Shouldn&#39;t that be the part where we are<br>
&gt;                 able to exchange<br>
&gt;                 them for other types of cells? So shouldn&#39;t it be<br>
&gt;                 typed to something<br>
&gt;                 like C extends AbstractCell&lt;A&gt; or so? Or is there<br>
&gt;                 another level where<br>
&gt;                 you want to introduce that?<br>
&gt;<br>
&gt;<br>
&gt;         What we will exchange for the is the Cells&lt; A, C &gt; cells that<br>
&gt;         is passed to the CellImg constructor.  ListImgCells implements<br>
&gt;         that interface such<br>
&gt;         that every Cell is stored as an Object.  If we would alter the<br>
&gt;         Cell type<br>
&gt;         here, than there would still be an Object required for cells<br>
&gt;         that are<br>
&gt;         currently not in memory.  So the idea was to change the Cells&lt;<br>
&gt;         A, C &gt;<br>
&gt;         implementation from ListImgCells to something else, that does<br>
&gt;         the caching and creates Cell objects when required.<br>
&gt;<br>
&gt;         Currently, I&#39;m using &quot;new DefaultCell&lt; A &gt;(...)&quot; to create<br>
&gt;         cells to<br>
&gt;         create all the cells in the ListImgCells constructor. When we<br>
&gt;         type<br>
&gt;         ListImgCells to C extends AbstractCell&lt;A&gt;, we would need to<br>
&gt;         pass a<br>
&gt;         type variable into the constructor and add a createNewCell()<br>
&gt;         method<br>
&gt;         to the AbstractCell.  This could be done, but let&#39;s wait until<br>
&gt;         we<br>
&gt;         actually need it.<br>
&gt;<br>
&gt;         The current idea is to exchange the Cells&lt; A, C &gt;<br>
&gt;         implementation.<br>
&gt;<br>
&gt;         best regards,<br>
&gt;         Tobias<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;                 Ciao ciao,<br>
&gt;                 Steffi<br>
&gt;<br>
&gt;                 On Mar 15, 2012, at 16:57 , Tobias Pietzsch wrote:<br>
&gt;<br>
&gt;                         Hi,<br>
&gt;<br>
&gt;                         I&#39;ve implemented more changes to the ImgLib2<br>
&gt;                         abstract class hierarchy.<br>
&gt;                         This time, I restructured the integer<br>
&gt;                         Positionables, Localizables, and<br>
&gt;                         RandomAccesses.<br>
&gt;<br>
&gt;                         While I was at it, I merged a new version of<br>
&gt;                         CellImg (this is in<br>
&gt;                         preparation for CellImgs that swap Cells to<br>
&gt;                         disk) because I didn&#39;t<br>
&gt;                         want to need to fix that for the new abstract<br>
&gt;                         hierarchy later.<br>
&gt;                         ListImg has also been changed a bit. And I<br>
&gt;                         made some cosmetic changes<br>
&gt;                         here and there...<br>
&gt;<br>
&gt;                         I think I broke nothing and I would merge this<br>
&gt;                         into master soon.<br>
&gt;<br>
&gt;                         It would be totally awesome, if you could try<br>
&gt;                         your ImgLib2 stuff with<br>
&gt;                         the branch &quot;modified-abstract-hierarchy&quot; and<br>
&gt;                         see if everything works<br>
&gt;                         okay. If you have time to comment on the<br>
&gt;                         changes I made - even better.<br>
&gt;<br>
&gt;                         best regards,<br>
&gt;                         Tobias<br>
&gt;<br>
&gt;                         BTW: did you see the cool fractal example on<br>
&gt;                         <a href="http://fiji.sc/wiki/index.php/ImgLib2_Documentation#A_RealRandomAccess_to_Render_Mandelbrot_Fractals" target="_blank">http://fiji.sc/wiki/index.php/ImgLib2_Documentation#A_RealRandomAccess_to_Render_Mandelbrot_Fractals</a><br>


&gt;                         ?<br>
&gt;                         :-)<br>
&gt;<br>
&gt;                         On 03/13/2012 09:01 PM, Tobias Pietzsch wrote:<br>
&gt;                                 Hi guys,<br>
&gt;<br>
&gt;                                 while I was writing ImgLib docs, I<br>
&gt;                                 noticed that the current<br>
&gt;                                 abstract class hierarchy which leads<br>
&gt;                                 to AbstractRandomAccess&lt;T&gt;<br>
&gt;                                 is a little bit stupid (see attached<br>
&gt;                                 imglib2-abstract-current.png)<br>
&gt;<br>
&gt;                                 There is no need for the abstract<br>
&gt;                                 class hierarchy to pull the<br>
&gt;                                 Sampler&lt;T&gt; interface all the way<br>
&gt;                                 through. The Sampler&lt;T&gt; is only<br>
&gt;                                 implemented in the concrete classes.<br>
&gt;                                 There is really no need to have<br>
&gt;                                 the dependency on T in the abstract<br>
&gt;                                 hierarchy. This prevents for<br>
&gt;                                 instance RealPoint to make use of the<br>
&gt;                                 RealPositionable and<br>
&gt;                                 RealLocalizable implementations in<br>
&gt;                                 AbstractRealRandomAccess&lt;T&gt;.<br>
&gt;<br>
&gt;                                 Therefore I propose to change the<br>
&gt;                                 hierarchy as shown in the<br>
&gt;                                 second attached diagram,<br>
&gt;                                 imglib2-abstract-proposed.png.<br>
&gt;<br>
&gt;                                 I implemented those changes for the<br>
&gt;                                 &quot;real&quot; path, see branch<br>
&gt;                                 &quot;modified-abstract-hierarchy&quot;. Note<br>
&gt;                                 how nicely RealPoint fits<br>
&gt;                                 into the picture now :-)<br>
&gt;                                 Before I go ahead and do the same for<br>
&gt;                                 the integer accessors, I wanted<br>
&gt;                                 to ask whether you agree that this is<br>
&gt;                                 a good thing to do...<br>
&gt;<br>
&gt;                                 There is one more thing: The<br>
&gt;                                 AbstractRealRandomAccess implemented<br>
&gt;                                 the complete RealPositionable<br>
&gt;                                 interface, while AbstractRandomAccess<br>
&gt;                                 only implements part of Positionable -<br>
&gt;                                 with the implemented part<br>
&gt;                                 based on the unimplemented methods.<br>
&gt;                                 The idea was that if a derived<br>
&gt;                                 concrete accessor compiles you know<br>
&gt;                                 you implemented what was necessary.<br>
&gt;<br>
&gt;                                 However, I found the approach of<br>
&gt;                                 AbstractRealRandomAccess to implement<br>
&gt;                                 anything quite nice when using it. I<br>
&gt;                                 would suggest doing the same for<br>
&gt;                                 integer. Then either<br>
&gt;                                 * you know what you are doing when<br>
&gt;                                 overriding (parts of) the<br>
&gt;                                 Positionable implementation<br>
&gt;                                 * you leave it as is (e.g. Point)<br>
&gt;                                 * you derive from AbstractLocalizable<br>
&gt;                                 and implement Positionable<br>
&gt;                                 completely on your own.<br>
&gt;<br>
&gt;                                 Thoughts?<br>
&gt;<br>
&gt;                                 best regards,<br>
&gt;                                 Tobias<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;                                 _______________________________________________<br>
&gt;                                 ImageJ-devel mailing list<br>
&gt;                                 <a href="mailto:ImageJ-devel@imagej.net">ImageJ-devel@imagej.net</a><br>
&gt;                                 <a href="http://imagej.net/mailman/listinfo/imagej-devel" target="_blank">http://imagej.net/mailman/listinfo/imagej-devel</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
</div></div></blockquote></div><br>