imglib / imglib2

A generic next-generation Java library for image processing
http://imglib2.net/
Other
293 stars 93 forks source link

Let RandomAccessibleInterval extend IterableInterval with default implementation #361

Closed tpietzsch closed 2 months ago

tpietzsch commented 3 months ago

There is really no reason that RandomAccessibleInterval should not be Iterable. We already can make any RAI iterable using Views.iterable(). With default implementations of IterableInterval in RandomAccessibleInterval, there is no overhead for implementers of RandomAccessibleInterval (unless they want to support more efficient, specialized cursors).

Consequences:

I fixed one new bug that was introduced by this:

void doSomething(IterableInterval<T> ii)
{
    ...
}

void doSomething(RandomAccessibleInterval<T> rai)
{
    doSomething(Views.flatIterable(ii)); // This becomes a circular recursion now
}

Probably there will be a few more bugs of this form. But I think the added convenience of returning RAI from Views.flatIterable() is worth it.

imagesc-bot commented 2 months ago

This pull request has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/recent-and-upcoming-imglib2-improvements/96083/3