Stream of a reverse list
Remi Forax
forax at univ-mlv.fr
Mon Jul 15 06:53:23 PDT 2013
On 07/15/2013 03:36 PM, Brian Goetz 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
We reject having a method reverse() on Stream but not the fact that one
can create a Stream that will iterate over the list in a backward way.
But perhaps, it's better to have a method of List named reverseList()
that return a reverse view of the list
and calls stream() on it.
Rémi
>
> On Jul 15, 2013, at 9:28 AM, Joe Bowbeer <joe.bowbeer at gmail.com
> <mailto: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
>> <mailto: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
>>
More information about the lambda-libs-spec-experts
mailing list