java - Stream of boolean values, is any true? -
I want to parallel the code given below using parallel stream:
Boolean anyTrue () {For (Element E: set off) {if (eval (e)) {Back true; } } return false; } Will the following tasks and regular short-circuit evaluation be used on parallel streams?
setOfE.parallelStream (). Map (e -> gt; eval (e)). Less (false, (A, B) -> A )
< P> The Stream API is actually the first class support for your requirement: setOfE.parallelStream (). Any match (e-> eval (e)); Unlike your approach with reduce , short-circuit evaluation and compatibility is guaranteed to be equally leverage.
Comments
Post a Comment