Concat operation

Paul Benedict pbenedict at apache.org
Tue Sep 18 07:15:05 PDT 2012


Shouldn't it be illegal to concat on an infinite stream? I propose throwing
ISE if the target stream is infinite.

On Tue, Sep 18, 2012 at 7:12 AM, Paul Sandoz <paul.sandoz at oracle.com> wrote:

> Hi,
>
> Please see here for a first go at implementing concat:
>
>   http://cr.openjdk.java.net/~psandoz/lambda/concat/webrev/
>
> I chose to implement:
>
>   stream.concat(anotherStream)
>
> so that the elements of "anotherStream" are concatenated on to end of
> "stream".
>
> This operation has side-effects.
>
> I am not sure how this operation relates to MapStream.mergeWith.
>
> I pulled out the concatenating of Iterator<Iterator<T>> from TreeUtils,
> spruced (no pun intended) it up, and placed it in Iterators for reuse.
>
> There is only the dumb parallel implementation. One wonders for the
> parallel case whether concat should be pseudo-random interleave :-)
>
> I updated the StreamOpTestCase exercise methods to take a
> Factory<IntermediateOp[]> since concat has side-effects:
>
>         exerciseFOp(data, () -> ConcatOp.make(data.seqStream()));
>
> (Another TODO for these test methods is to select which cases to test).
>
> Paul.
>
>


More information about the lambda-dev mailing list