ints(), longs(), doubles() <was> Re: Ranges
Paul Sandoz
paul.sandoz at oracle.com
Fri May 3 07:53:03 PDT 2013
On May 3, 2013, at 3:00 PM, Tim Peierls <tim at peierls.net> wrote:
> On Fri, May 3, 2013 at 4:46 AM, Paul Sandoz <paul.sandoz at oracle.com> wrote:
> Following on from this are the idiomatic stream creation methods, we have previously discussed:
>
> IntStream.ints();
> LongStream.longs();
> DoubleStream.doubles();
>
> Half-open, or closed? I think a closed range would be the most likely expectation, and could be implemented using rangeClosed.
>
> doubles() would be restricted to [0.0, 2.0^53].
>
> I've missed something. How will the user see a difference between ints() implemented as a closed range vs. a half-open range?
>
The closed range will be for all non-negative int values, where as the half open will be for all non-negative int values except Integer.MAX_VALUE.
e.g. the difference between:
for (int i = 0; i < Integer.MAX_VALUE; i++) { ... }
and:
for (int i = 0; i <= Integer.MAX_VALUE && i >= 0; i++) { ... }
Paul.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/lambda-libs-spec-experts/attachments/20130503/6b00968b/attachment.html
More information about the lambda-libs-spec-experts
mailing list