To Stream.slice(fromInclusive, toExclusive) or Stream.slice(toSkip, limit) that is the question
spullara at gmail.com
Fri Oct 11 13:25:04 PDT 2013
Couldn't a negative limit be seen the same way if we wanted it to?
---Sent from Boxer
On Fri, Oct 11, 2013 at 01:12 PM, Joe Bowbeer wrote:Thanks for the example. In terms of readability, I think skip(offset).limit(size) works well in this case. I think slice(offset, offset+size) works fine here, as well. By the way, slice(start, end) has another potential advantage in that negative values for the 'end' argument can be interpreted as an offset from the end -- skipping the final x entries. --Joe On Fri, Oct 11, 2013 at 10:34 AM, Brian Goetz <brian.goetz at oracle.com> 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);
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the lambda-libs-spec-experts