On Jun 4, 2015, at 10:27 AM, Peter Levart <peter.lev...@gmail.com> wrote:
> 
> On 06/03/2015 08:53 PM, Peter Levart wrote:
>> Hi Paul,
>> 
>> This is a usefull addition to Stream API for sequential ordered streams. But 
>> does it have any utility in unordered streams at all? Wouldn't it be better 
>> to just throw an IllegalStateException or something if the stream is not 
>> ordered? I can't imagine currently a situation where I would need to select 
>> an arbitrary sub-set of the stream where all elements match a predicate and 
>> I would not be given any guarantee about how big a subset I will get - the 
>> same with a stream where an arbitrary sub-set of elements matching predicate 
>> is taken away. If I wanted something similar for unordered stream, I would 
>> rather say: "Give me at most N elements of the stream matching predicate" 
>> for example - and that can already be achieved by .filter().limit();
>> 
>> So any use of [take|drop]While on unordered stream would most probably be 
>> unintended and consequently could be considered a bug, don't you think?
> 
> Ok, I take back. I was only thinking in terms of the [take|drop]While 
> Predicate being a function of the stream element. Now that I see an example 
> where it is a function of time, I can understand it's utility even for 
> unordered streams.
> 

Right, i was about to reply pointing out that aspect.

This is a tricky area, i expect it will keep some people rather busy on 
stackoverflow :-)

Paul.

Reply via email to