To Stream.slice(fromInclusive, toExclusive) or Stream.slice(toSkip,	limit) that is the question
    Brian Goetz 
    brian.goetz at oracle.com
       
    Fri Oct 11 07:06:48 PDT 2013
    
    
  
> 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!  The sequential 
implementation is fast no matter what you do.  But skip and limit are 
constrained to operate in *encounter order* -- you don't just skip any 
N, you skip the *first N*.  This is death for parallel operations, 
unless there's something else you can do to sidestep the problem (which 
we do for streams with predictable size and splitting characteristics, 
or for unordered streams.)
As a general rule, whenever you find yourself thinking "I don't 
understand why they just don't...", the answer is probably because 
you've got your sequential goggles on, which filters the hard part from 
your view.
    
    
More information about the lambda-libs-spec-observers
mailing list