RFR 8071597 Add Stream dropWhile and takeWhile operations

Paul Sandoz Paul.Sandoz at oracle.com
Tue Jun 9 07:20:40 UTC 2015


HI Stefan,

On Jun 7, 2015, at 10:07 PM, Stefan Zobel <spliterator at gmail.com> wrote:

> I'm still trying to wrap my head around the test logic for the (par & !ord)
> && (op == WhileOp.Drop) case
> in the whileResultAsserter() method in WhileOpTest.
> 
> Wouldn't it be possible that, for an unordered parallel stream, dropWhile()
> won't drop anything at all (i.e.,
> drops an empty set)?
> 

Yes.


> In that case, input.size() == output.size() and the set of matching output
> elements is no longer a _proper_ subset
> of the set of matching input elements. The whileResultAsserter() would fail
> even though dropWhile() works correctly
> (in a nondeterministic sense)?
> 
> It's a bit late now and I guess it's all in my imagination. Still curious
> ...
> 

I don't think you are imagining things, thanks for looking. The proper subset is incorrect, i confused myself :-)

For example, if we have the input set {1, 2, 3} and the predicate i < 3, then a valid output set is {1, 2, 3} if the imputed order observed is [3, 2, 1] or [3, 1, 2]

I adjusted the test code accordingly.

Thanks,
Paul.



More information about the core-libs-dev mailing list