public void RemoveAllWorks()
 {
     var c = new FastCollection<int> { 1, 2, 3, 4, 5 };
     c.RemoveAll(x => x % 2 == 0);
     AssertEquals(c, new[] { 1, 3, 5 });
     c.RemoveAll(x => false);
     AssertEquals(c, new[] { 1, 3, 5 });
     c.RemoveAll(x => true);
     Assert.Equal(0, c.Count);
     Assert.False(c.Any());
     c.RemoveAll(x => true);
     Assert.Equal(0, c.Count);
     Assert.False(c.Any());
 }
 public void DoesntHoldReferencesRemoveAll()
 {
     var wr1 = new WeakReference(new object());
     var wr2 = new WeakReference(new object());
     var c = new FastCollection<object> { wr1.Target, wr2.Target };
     GCEx.CollectAndWait();
     Assert.Equal(2, c.Count);
     Assert.True(wr1.IsAlive);
     Assert.True(wr2.IsAlive);
     c.RemoveAll(x => x == wr1.Target);
     GCEx.CollectAndWait();
     Assert.Equal(1, c.Count);
     Assert.False(wr1.IsAlive);
     Assert.True(wr2.IsAlive);
     c.RemoveAll(x => x == wr2.Target);
     GCEx.CollectAndWait();
     Assert.Equal(0, c.Count);
     Assert.False(wr1.IsAlive);
     Assert.False(wr2.IsAlive);
 }