本文整理汇总了C#中CircularBuffer.EnqueueRange方法的典型用法代码示例。如果您正苦于以下问题:C# CircularBuffer.EnqueueRange方法的具体用法?C# CircularBuffer.EnqueueRange怎么用?C# CircularBuffer.EnqueueRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CircularBuffer
的用法示例。
在下文中一共展示了CircularBuffer.EnqueueRange方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CircularBuffer_CopyTo
public void CircularBuffer_CopyTo()
{
var data = new[] { 12, 4, 9, 43, 0 };
var buffer = new CircularBuffer<int>(10);
buffer.EnqueueRange(data, 0, data.Length);
var dataCopy = new int[5];
buffer.CopyTo(dataCopy, 0, 5);
CollectionAssert.AreEqual(new[] { 12, 4, 9, 43, 0 }, dataCopy);
}
示例2: CircularBuffer_EnqueueAfterTrimExcess
public void CircularBuffer_EnqueueAfterTrimExcess()
{
var buffer = new CircularBuffer<string>(10);
buffer.EnqueueRange(new[] { "a", "b", "c" }, 0, 3);
buffer.TrimExcess();
buffer.Enqueue("z");
CollectionAssert.AreEqual(new[] { "z", "b", "c" }, buffer.ToArray());
Assert.AreEqual(3, buffer.Count);
Assert.AreEqual(3, buffer.Capacity);
Assert.AreEqual(0, buffer.Head);
Assert.AreEqual(1, buffer.Tail);
Assert.IsTrue(buffer.Contains("z"));
Assert.IsFalse(buffer.Contains("a"));
}
示例3: CircularBuffer_Dequeue
public void CircularBuffer_Dequeue()
{
int[] data = { 0, 1, 2, 3 };
var buffer = new CircularBuffer<int>(data.Length);
buffer.EnqueueRange(data, 0, data.Length);
buffer.Dequeue();
Assert.AreEqual(3, buffer.Count);
Assert.AreEqual(data.Length, buffer.Capacity);
Assert.AreEqual(1, buffer.Head);
Assert.AreEqual(0, buffer.Tail);
Assert.IsTrue(buffer.Contains(1));
Assert.IsFalse(buffer.Contains(0));
CollectionAssert.AreEqual(new[] { 1, 2, 3 }, buffer.ToArray());
}
示例4: CircularBuffer_EnqueueOverwriteAllowed
public void CircularBuffer_EnqueueOverwriteAllowed()
{
string[] data = { "a", "b", "c", "d" };
var buffer = new CircularBuffer<string>(data.Length);
buffer.EnqueueRange(data, 0, data.Length);
buffer.Enqueue("z");
CollectionAssert.AreEqual(new[] { "z", "b", "c", "d" }, buffer.ToArray());
Assert.AreEqual(data.Length, buffer.Count);
Assert.AreEqual(data.Length, buffer.Capacity);
Assert.AreEqual(0, buffer.Head);
Assert.AreEqual(1, buffer.Tail);
Assert.IsTrue(buffer.Contains("z"));
Assert.IsFalse(buffer.Contains("a"));
}
示例5: CircularBuffer_IndexerGet
public void CircularBuffer_IndexerGet()
{
var buffer = new CircularBuffer<int>(10);
buffer.EnqueueRange(
new[] { 12, 4, 9, 43, 0 },
0, 5);
Assert.AreEqual(12, buffer[0]);
Assert.AreEqual(0, buffer[4]);
buffer.TrimExcess();
buffer.EnqueueRange(new[] { 99, 100 }, 0, 2);
Assert.AreEqual(99, buffer[0]);
Assert.AreEqual(9, buffer[2]);
}
示例6: CircularBuffer_EnqueueOverwriteNotAllowed
public void CircularBuffer_EnqueueOverwriteNotAllowed()
{
int[] data = { 1, 2, 3, 4, 5 };
var buffer = new CircularBuffer<int>(data.Length, false);
buffer.EnqueueRange(data, 0, data.Length);
buffer.Enqueue(10);
}