To Stream.slice(fromInclusive, toExclusive) or Stream.slice(toSkip, limit) that is the question
Stephen Colebourne
scolebourne at joda.org
Fri Oct 11 07:18:18 PDT 2013
On 11 October 2013 15:06, Brian Goetz <brian.goetz at oracle.com> wrote:
>> skip() and limit() make perfect sense. I'm surprised by the notion
>> that skip(60).limit(10) would be less efficient than
>> skipAndLimit(60,10)
>
> That's because you're thinking sequentially!
No, I wasn't thinking at all about the implementation. I was
commenting on API design.
If skipAndLimit(60, 10) is an important enough optmization, I'd really
want the implementation to do that for me - one less concern for me as
a user. Especially important as the API trades on the notion that you
just build up a request from a sequence of small fluent commands.
If you can't make the optimization internal, then it would be much
better to call the method skipAndLimit() or skipLimit() as then it
will appear next to skip() in IDEs and people might, just might, pause
and think about using the combined operation.
Stephen
More information about the lambda-libs-spec-observers
mailing list