Stream of a reverse list

Brian Goetz brian.goetz at oracle.com
Mon Jul 15 06:36:41 PDT 2013


We did consider such a stream op and triaged it away as bring too niche. It also requires a full barrier to get the first element.  And for infinite streams obviously blows up.  

Given that it always requires a full barrier, toArray seems the best way to go. 

Sent from my iPad

On Jul 15, 2013, at 9:28 AM, Joe Bowbeer <joe.bowbeer at gmail.com> wrote:

> It seems like overkill to add a specific method for what is likely to be a general problem, but it's not clear to me what the best general solution is...
> 
> One option is to create an IntStream of reversed indices, using iterate(), then map that to a stream of elements.
> 
> Can generate() be used in this situation to generate the reversed stream directly?
> 
> --Joe
> 
> On Jul 15, 2013 2:41 AM, "Remi Forax" <forax at univ-mlv.fr> wrote:
>> How to get a stream of a list in reverse order without actually reversing the list ?
>> 
>> do we need a List.reverseStream() or there is another way ?
>> 
>> Rémi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/lambda-libs-spec-experts/attachments/20130715/3825c3e6/attachment.html 


More information about the lambda-libs-spec-experts mailing list