To Stream.slice(fromInclusive, toExclusive) or Stream.slice(toSkip, limit) that is the question
David M. Lloyd
david.lloyd at redhat.com
Fri Oct 11 12:10:14 PDT 2013
On 10/11/2013 12:34 PM, Brian Goetz wrote:
>> If you have a non-indexed stream, why would you ever
>> skip(start).limit(count) instead of simply limit(count)?
> Here's one use case: Paging. You've got a stream of results, and you
> want to display them by pages.
> Stream results = input.skip((pageNo-1)*pageSize).limit(pageSize);
A very similar problem (and solution) exists in the RDBMS world; though
(IIRC) there is no standardized mechanism, just about every major SQL
RDBMS supports a (conceptually) very similar construct for choosing a
subset of results, for very similar use cases (AFAICT). Take that for
what it's worth.
More information about the lambda-libs-spec-experts