Stream of a reverse list

Joe Bowbeer joe.bowbeer at gmail.com
Mon Jul 15 07:15:17 PDT 2013


Is there a general method recommended for creating a special-order stream
from a collection?

Is generate() appropriate here, even in the sequential case?

Joe
On Jul 15, 2013 6:36 AM, "Brian Goetz" <brian.goetz at oracle.com> wrote:

> 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/a1f6e7fd/attachment.html 


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