title: Java 8 stream short-circuit
body: <p>Reading up a bit on Java 8, I got to <a href="https://thecannycoder.wordpress.com/2014/08/10/collectors-part-1-reductions-and-short-circuiting-operations%E2%80%8F/">this</a> blog post explaining a bit about streams and reduction of them, and when it would be possible to short-circuit the reduction. At the bottom it states: </p>
  
  <blockquote>
    <p>Note in the case of <code>findFirst</code> or <code>findAny</code> we only need the first value which matches the predicate (although <code>findAny</code> is not guaranteed to return the first). However if the stream has no ordering then we’d expect <code>findFirst</code> to behave like <code>findAny</code>. The operations <code>allMatch</code>, <code>noneMatch</code> and <code>anyMatch</code> may not short-circuit the stream at all since it may take evaluating all the values to determine whether the operator is <code>true</code> or <code>false</code>. Thus an infinite stream using these may not terminate.</p>
  </blockquote>
  
  <p>I get that <code>findFirst</code> or <code>findAny</code> may short-circuit the reduction, because as soon af you find an element, you don't need to process any further. </p>
  
  <p>But why would this not be possible for <code>allMatch</code>, <code>noneMatch</code> and <code>anyMatch</code>? For <code>allMatch</code>, if you find one which doesn't match the predicate, you can stop processing. Same for none. And <code>anyMatch</code> especially doesn't make sense to me, as it it pretty much equal to <code>findAny</code> (except for what is returned)?</p>
  
  <p>Saying that these three may not short-circuit, because it may take evaluating all the values, could also be said for <code>findFirst/Any</code>.</p>
  
  <p>Is there some fundamental difference I'm missing? Am I not really understanding what is going on?</p>