本文整理汇总了C#中CircularBuffer.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# CircularBuffer.Remove方法的具体用法?C# CircularBuffer.Remove怎么用?C# CircularBuffer.Remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CircularBuffer
的用法示例。
在下文中一共展示了CircularBuffer.Remove方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Remove_RemoveSecondItem_OrderIsRight
public void Remove_RemoveSecondItem_OrderIsRight()
{
var target = new CircularBuffer<int>(4) { 1, 2, 3, 4 };
target.Remove(2);
var expected = new List<int> { 1, 3, 4 };
Assert.IsTrue(target.SequenceEqual(expected));
Assert.IsTrue(target.Capacity == 4);
}
示例2: Remove_RemoveSecondItemAndAddTwoItems_OrderIsRight
public void Remove_RemoveSecondItemAndAddTwoItems_OrderIsRight()
{
//Create a circular buffer where the first item is overridden
var target = new CircularBuffer<int>(3) { 1, 2, 3, 4 };
target.Remove(2);
target.Add(5);
target.Add(6);
var expected = new List<int> { 6, 3, 5 };
Assert.IsTrue(target.SequenceEqual(expected));
Assert.IsTrue(target.Capacity == 3);
}
示例3: Remove_ValueType_RemovesItem
public void Remove_ValueType_RemovesItem()
{
var buffer = new CircularBuffer<int>(3);
buffer.Add(1);
buffer.Add(2);
buffer.Add(3);
buffer.Remove(2);
Assert.AreEqual(2, buffer.Count);
Assert.IsTrue(buffer.Contains(1));
Assert.IsFalse(buffer.Contains(2));
Assert.IsTrue(buffer.Contains(3));
}
示例4: Remove_ReferenceType_RemovesItem
public void Remove_ReferenceType_RemovesItem()
{
var buffer = new CircularBuffer<TestRefType>(3);
var o1 = new TestRefType(Guid.NewGuid());
var o2 = new TestRefType(Guid.NewGuid());
var o3 = new TestRefType(Guid.NewGuid());
buffer.Add(o1);
buffer.Add(o2);
buffer.Add(o3);
buffer.Remove(o2);
Assert.AreEqual(2, buffer.Count);
Assert.IsTrue(buffer.Contains(o1));
Assert.IsFalse(buffer.Contains(o2));
Assert.IsTrue(buffer.Contains(o3));
}