Open ctrueden opened 11 years ago
2013/4/30 Curtis Rueden notifications@github.com
It would be nice to be able to have an object which is Iterable but not necessarily an Interval or RealInterval. So far we have been using Java's Iterable class, but we want to extend it to support the cursor() method to return a Cursor (in the case of Iterable) or RealCursor (in the case of RealIterable).
The original thinking for not having a non-Interval Iterable was that there are always a finite number of elements in the iteration and hence ultimately there are min and max bounds for the Interval from those. But that is questionable: Java's Iterable actually does not enforce there being a limit to the iteration (i.e., there is no size() method). Of course, Java's Iterable was intended for use with the Collections framework, and all Collections have an int size(), but ImgLib2 does not use Collection directly. (Some types define a size() but it is typically a long, for example.) Of course, if your Iterable isn't actually finite, there are other serious problems: a naive iteration loop over all elements will never terminate—in practice, ImgLib2 has an implicit assumption that all Iterables have a finite number of elements.
I'd say instead that, if anything, a view on an iterable has a limited number of elements (and not even views may be limited). An iterable per se may be a function that can generate values for any field of view, like Mandelbrot's fractal.
Albert
Do you have a specific application in mind?
Phyllotaxis samples from a fractal? :-D
It would be nice to be able to have an object which is
Iterable
but not necessarily anInterval
orRealInterval
. So far we have been using Java'sIterable
class, but we want to extend it to support thecursor()
method to return aCursor
(in the case ofIterable
) orRealCursor
(in the case ofRealIterable
).The original thinking for not having a non-
Interval
Iterable
was that there are always a finite number of elements in the iteration and hence ultimately there are min and max bounds for theInterval
from those. But that is questionable: Java'sIterable
actually does not enforce there being a limit to the iteration (i.e., there is nosize()
method). Of course, Java'sIterable
was intended for use with the Collections framework, and allCollection
s have anint size()
, but ImgLib2 does not useCollection
directly. (Some types define asize()
but it is typically along
, for example.) Of course, if yourIterable
isn't actually finite, there are other serious problems: a naive iteration loop over all elements will never terminate—in practice, ImgLib2 has an implicit assumption that allIterable
s have a finite number of elements.