How "unordered" helps "distinct()" and "groupingBy"
<p>I am doing the Oracle's Stream API Java 1.8 course and I stumbled upon this while perusing the lecture notes:</p>
<blockquote>
<p>unordered():</p>
<p>– Inherited from BaseStream</p>
<p>– Returns a stream that is unordered (used internally)</p>
<p>– Can improve efficiency of operations like distinct() and groupingBy()</p>
</blockquote>
<p>Here is my question. How can the property of being unordered lead to more efficient calculation of <code>distinct()</code> and <code>groupingBy()</code></p>