Most efficient collection for filtering a Java Stream?
<p>I'm storing several <code>Thing</code>s in a Collection. The individual <code>Thing</code>s are unique, but their types aren't. The order in which they are stored also doesn't matter.</p>

<p>I want to use Java 8's Stream API to search it for a specific type with this code:</p>

<pre><code>Collection&lt;Thing&gt; things = ...;
// ... populate things ...
Stream&lt;Thing&gt; filtered = things.stream.filter(thing -&gt; thing.type.equals(searchType));
</code></pre>

<p>Is there a particular <code>Collection</code> that would make the <code>filter()</code> more efficient?</p>

<p>I'm inclined to think no, because the filter has to iterate through the entire collection. </p>

<p>On the other hand, if the collection is some sort of tree that is indexed by the <code>Thing.type</code> then the <code>filter()</code> might be able to take advantage of that fact. Is there any way to achieve this?</p>