本文整理汇总了C#中CircularBuffer.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# CircularBuffer.AddRange方法的具体用法?C# CircularBuffer.AddRange怎么用?C# CircularBuffer.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CircularBuffer
的用法示例。
在下文中一共展示了CircularBuffer.AddRange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestSizeIncrease
public void TestSizeIncrease()
{
int bufferSize = 3;
CircularBuffer<int> circularBuffer = new CircularBuffer<int>(bufferSize);
circularBuffer.AddRange(new int[]{0, 1});
// Increase when not yet full
bufferSize = 5;
circularBuffer.Size = bufferSize;
VerifyContent(circularBuffer, 0 , 1);
// fill up
for (int i = 2; i < 5; i++)
{
circularBuffer.Add(i);
VerifyContent(circularBuffer, 0, i);
}
// roll over
for (int i = 5; i < 8; i++)
{
circularBuffer.Add(i);
VerifyContent(circularBuffer, i - bufferSize + 1, i);
}
// Increase when full
bufferSize = 7;
circularBuffer.Size = bufferSize;
VerifyContent(circularBuffer, 3, 7);
// fill up
for (int i = 8; i < 10; i++)
{
circularBuffer.Add(i);
VerifyContent(circularBuffer, 3, i);
}
// roll over
for (int i = 10; i < 12; i++)
{
circularBuffer.Add(i);
VerifyContent(circularBuffer, i - bufferSize + 1, i);
}
}