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

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -