Convert old "into" code to the collectors

Marcos Antonio marcos_antonio_ps at hotmail.com
Wed Jan 16 09:09:22 PST 2013


----------------------------------------
> Subject: Re: Convert old "into" code to the collectors
> From: paul.sandoz at oracle.com
> Date: Wed, 16 Jan 2013 17:57:59 +0100
> CC: lambda-dev at openjdk.java.net
>
>
> On Jan 16, 2013, at 5:25 PM, Marcos Antonio <marcos_antonio_ps at hotmail.com> wrote:
>
> >
> > So the bottom line is that I cannot use an existing collection anymore as I used to do with the "into" method, right?
> > Are there any alternatives?
> >
>
> The simplest way to add to an existing collection *sequentially* is to do:
>
> Collection c = ...
> s.forEach(c::add);
>
> If you are going parallel then you will need to place a sequential barrier before the forEach:
>
> parStream.sequential().forEach(c:add);
>
> Paul.

Yes, that's the way I'm using now.

Marcos 		 	   		  


More information about the lambda-dev mailing list