本文整理汇总了C#中Queue.Size方法的典型用法代码示例。如果您正苦于以下问题:C# Queue.Size方法的具体用法?C# Queue.Size怎么用?C# Queue.Size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Queue
的用法示例。
在下文中一共展示了Queue.Size方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Enqueue_Header_Null_Test
public void Enqueue_Header_Null_Test()
{
var queue = new Queue<int>();
queue.Enqueue(9);
Assert.AreEqual(1, queue.Size());
Assert.AreEqual(9, queue.Peek());
queue.Enqueue(11);
Assert.AreEqual(2, queue.Size());
Assert.AreEqual(11, queue.Peek());
}
示例2: Run
public void Run()
{
const string fieName = "tobe.txt";
var @in = new In($"Files\\Collections\\{fieName}");
var words = @in.ReadAllStrings();
var queue = new Queue<string>();
foreach (var word in words)
{
queue.Enqueue(word);
}
Console.WriteLine("size of queue = {0}", queue.Size());
foreach (var item in queue)
{
Console.WriteLine("item = {0}", item);
}
while (!queue.IsEmpty())
{
var item = queue.Dequeue();
Console.WriteLine("item = {0}", item);
}
Console.ReadLine();
}
示例3: QueueDequeueOne
public void QueueDequeueOne()
{
Queue<int> q = new Queue<int>();
q.Enqueue(0);
int n = q.Dequeue();
Assert.AreEqual(0, q.Size());
Assert.AreEqual(0, n);
}
示例4: QueueEnqueueMultiple
public void QueueEnqueueMultiple()
{
Queue<int> q = new Queue<int>();
for(int i=0; i<10; i++)
{
q.Enqueue(i);
}
Assert.AreEqual(10, q.Size());
}
示例5: Dequeue_One_Item_Test
public void Dequeue_One_Item_Test()
{
var queue = new Queue<int>();
queue.Enqueue(9);
var item = queue.Dequeue();
Assert.AreEqual(0, queue.Size());
Assert.AreEqual(9, item);
}
示例6: QueueDequeueMultiple
public void QueueDequeueMultiple()
{
Queue<int> q = new Queue<int>();
for(int i=0; i<10; i++)
{
q.Enqueue(i);
}
int n1 = q.Dequeue();
int n2 = q.Dequeue();
Assert.AreEqual(8, q.Size());
Assert.AreEqual(0, n1);
Assert.AreEqual(1, n2);
}
示例7: Size_Zero_Test
public void Size_Zero_Test()
{
var queue = new Queue<int>();
Assert.AreEqual(0, queue.Size());
}
示例8: QueueDequeueEmpty
public void QueueDequeueEmpty()
{
Queue<int> q = new Queue<int>();
q.Dequeue();
Assert.AreEqual(0, q.Size());
}
示例9: QueueEnqueueOne
public void QueueEnqueueOne()
{
Queue<int> q = new Queue<int>();
q.Enqueue(0);
Assert.AreEqual(1, q.Size());
}