This is related to my interest in a zero-length Range. I may have an
Array with values 1-10 and want to process a request for values > 10. I
have code that gets indices from a binary search and creates a Range
that is used to "section" the Array. Currently, I'm using nulls to
handle zero-length results, but it would be much nicer to have empty
Ranges and Arrays that would do the right thing.
Doug
John Caron wrote:
Konrad Hinsen wrote:
I am working on some code that uses the array implementation from netCDF
(ucar.ma2). One point I have been stumbling over is the support (or not)
of arrays that have a zero in their shape array and thus have no elements.
It is possible to create such elements using the factory method, and
they seem to be behave just fine. On the other hand, it is not possible
to obtain such an empty array as a subsection of another array, because
the Range constructor insists that 0 <= first <= last. I end up having
lots of special-case checks for empty subsections because in many places
in my code, empty arrays can be produced as a result for limiting cases
of the input parameters.
Is there any reason why Range does not accept last < first, resulting in
an empty array of the right shape?
Konrad.
I will have to look closer as to why these arent allowed. I have also noticed
that generates special-case checks. Can you tell me how you use this and an
example why zero-length arrays are useful to you?
_______________________________________________
netcdf-java mailing list
netcdf-java@xxxxxxxxxxxxxxxx
For list information or to unsubscribe, visit: http://www.unidata.ucar.edu/mailing_lists/