本文整理汇总了C#中Deque.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# Deque.Insert方法的具体用法?C# Deque.Insert怎么用?C# Deque.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Deque
的用法示例。
在下文中一共展示了Deque.Insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestInsert
public void TestInsert()
{
Deque<int> test = new Deque<int>(10);
test.Add(0);
test.Add(1);
test.Add(2);
test.Add(3);
test.Add(4);
test.Add(5);
test.Add(6);
test.Add(7);
test.Add(8);
test.Add(9);
test.RemoveAt(0);
test.RemoveAt(0);
test.Insert(3, 7);
test.Insert(3, 8);
CollectionAssert.AreEqual(test.ToArray(), new int[] { 2, 3, 4, 8, 7, 5, 6, 7, 8, 9 });
Assert.AreEqual(test.Count, 10);
}
示例2: TestBulkInsert
public void TestBulkInsert()
{
int loops = 100000;
Deque<int> deque = new Deque<int>();
deque.AddFront(loops - 1);
for (int i = 0; i < loops - 1; i++)
{
deque.Insert(deque.Count-1, i);
}
Deque<int> dequeCopy = new Deque<int>(deque);
for (int expected = 0; expected < loops; expected++)
{
int actual = deque.RemoveFront();
int actualCopy = dequeCopy[expected];
Assert.AreEqual(expected, actual, "Original deque item differs from expected value");
Assert.AreEqual(expected, actualCopy, "Copied deque item differs from expected value");
}
}