Filter duplicated items from enumerable
<p>I have an unordered enumeration that may contain duplicates, and I want to remove ALL items that have duplicates, and keep only those that occur only once in the original enumeration.</p>

<p>Example: A and C are removed since they occur more than once:</p>

<p>input {A,C,B,A,C,D,A}<br>
output {B,D}</p>

<p>A quick and dirty implementation could be:</p>

<pre><code>IEnumerable&lt;T&gt; Filter(IEnumerable&lt;T&gt; items)
{
   items.Where(item =&gt; items.Count(x =&gt; x.Equals(item)) == 1);
}
</code></pre>

<p>Obviously not quick or elegant. </p>

<p>The example below is still quadratic (slightly faster), but requires a ToList() call on the input. </p>

<pre><code>IEnumerable&lt;T&gt; Filter(IEnumerable&lt;T&gt; items)
{
    List&lt;T&gt; src = items.ToList();
    for(int i=0; i&lt;src.Count; i++)
    {
       if (src.IndexOf(src[i], i+1) &lt; 0)
         yield return src[i]; 
    }
}
</code></pre>

<p>How would you do this if you wanted it to be reasonably compact and readable (code wise) while still not brain-dead slow like these implementations?</p>
