public void AddRemoveWorks()
 {
     var c = new FastCollection<int> { 1, 2, 3, 4, 5 };
     Assert.True(c.SequenceEqual(new[] { 1, 2, 3, 4, 5 }));
     Assert.Equal(5, c.Count);
     var originalCapacity = c.Capacity;
     Assert.InRange(originalCapacity, 5, int.MaxValue);
     Assert.True(c.Remove(5));
     AssertEquals(c, new[] { 1, 2, 3, 4 });
     Assert.InRange(c.Capacity, 4, originalCapacity);
     c.RemoveAt(3);
     AssertEquals(c, new[] { 1, 2, 3 });
     Assert.InRange(c.Capacity, 3, originalCapacity);
     Assert.True(c.Remove(1));
     AssertEquals(c, new[] { 2, 3 });
     Assert.InRange(c.Capacity, 2, originalCapacity);
     Assert.False(c.Remove(1));
     var oneEl = c[1];
     c.RemoveAt(0);
     Assert.Equal(oneEl, c[0]);
     Assert.Equal(1, c.Count);
     c.Add(4);
     AssertEquals(c, new[] { oneEl, 4 });
     c.Clear();
     Assert.True(c.SequenceEqual(new int[0]));
     Assert.Equal(0, c.Count);
 }
 public T Take(IQuery <T> query)
 {
     for (var i = 0; i < _storage.Count; i++)
     {
         var item = _storage[i];
         if (!query.Match(item))
         {
             continue;
         }
         // move last item to it's place
         _storage.RemoveAt(i);
         return(item);
     }
     return(default(T));
 }