本文整理汇总了C#中Queue.GetElements方法的典型用法代码示例。如果您正苦于以下问题:C# Queue.GetElements方法的具体用法?C# Queue.GetElements怎么用?C# Queue.GetElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Queue
的用法示例。
在下文中一共展示了Queue.GetElements方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PopAndPush_LoopAndDoubleQueue
public void PopAndPush_LoopAndDoubleQueue()
{
int capacity = 3;
Queue<int> queue = new Queue<int>(capacity);
int[] expectedQueue = { 2, 1, 4, 5 };
queue.Push(3);
queue.Push(2);
queue.Push(1);
queue.Pop();
queue.Push(4);
queue.Push(5);
Assert.AreEqual(capacity * 2, queue.Capacity, "Capacity is not increased!");
CollectionAssert.AreEqual(expectedQueue, queue.GetElements());
}
示例2: Pop_3214elements_3returned
public void Pop_3214elements_3returned()
{
Queue<int> queue = new Queue<int>();
queue.Push(3);
queue.Push(2);
queue.Push(1);
queue.Push(4);
int[] expectedQueue = {2, 1, 4};
int actualNumber = queue.Pop();
Assert.AreEqual(3, actualNumber);
CollectionAssert.AreEqual(expectedQueue, queue.GetElements());
}
示例3: Push_OneMoreCapacityElements_SizeIsDoubled
public void Push_OneMoreCapacityElements_SizeIsDoubled()
{
int capacity = 3;
Queue<int> queue = new Queue<int>(capacity);
int[] expectedQueue = new int[capacity + 1];
for (int i = 0; i < capacity + 1; i++)
{
queue.Push(i);
expectedQueue[i] = i;
}
Assert.AreEqual(capacity * 2, queue.Capacity, "Capacity is not doubled!");
Assert.AreEqual(expectedQueue.Length, queue.Count, "Size is not right!");
CollectionAssert.AreEqual(expectedQueue, queue.GetElements());
}
示例4: Push_1and2_1and2returned
public void Push_1and2_1and2returned()
{
Queue<int> queue = new Queue<int>();
int[] expected = { 1, 2 };
queue.Push(1);
queue.Push(2);
Assert.AreEqual(expected.Length, queue.Count, "Size is not right!");
CollectionAssert.AreEqual(expected, queue.GetElements());
}