本文整理汇总了C#中CircularBuffer.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# CircularBuffer.IndexOf方法的具体用法?C# CircularBuffer.IndexOf怎么用?C# CircularBuffer.IndexOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CircularBuffer
的用法示例。
在下文中一共展示了CircularBuffer.IndexOf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestRemoveAt
public void TestRemoveAt()
{
var buffer = new CircularBuffer<long>(5);
Assert.AreEqual(default(long), buffer.Enqueue(1));
Assert.AreEqual(default(long), buffer.Enqueue(2));
Assert.AreEqual(default(long), buffer.Enqueue(3));
Assert.AreEqual(default(long), buffer.Enqueue(4));
Assert.AreEqual(default(long), buffer.Enqueue(5));
buffer.RemoveAt(buffer.IndexOf(2));
buffer.RemoveAt(buffer.IndexOf(4));
Assert.AreEqual(3, buffer.Count);
Assert.AreEqual(1, buffer.Dequeue());
Assert.AreEqual(3, buffer.Dequeue());
Assert.AreEqual(5, buffer.Dequeue());
Assert.AreEqual(0, buffer.Count);
Assert.AreEqual(default(long), buffer.Enqueue(1));
Assert.AreEqual(default(long), buffer.Enqueue(2));
Assert.AreEqual(default(long), buffer.Enqueue(3));
Assert.AreEqual(default(long), buffer.Enqueue(4));
Assert.AreEqual(default(long), buffer.Enqueue(5));
buffer.RemoveAt(buffer.IndexOf(1));
buffer.RemoveAt(buffer.IndexOf(3));
buffer.RemoveAt(buffer.IndexOf(5));
Assert.AreEqual(2, buffer.Count);
Assert.AreEqual(2, buffer.Dequeue());
Assert.AreEqual(4, buffer.Dequeue());
Assert.AreEqual(0, buffer.Count);
}