本文整理汇总了C#中Queue.DequeueAll方法的典型用法代码示例。如果您正苦于以下问题:C# Queue.DequeueAll方法的具体用法?C# Queue.DequeueAll怎么用?C# Queue.DequeueAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Queue
的用法示例。
在下文中一共展示了Queue.DequeueAll方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: QueueExtensions_DequeueAll
public void QueueExtensions_DequeueAll()
{
var input = new byte[] { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0 };
var queue = new Queue<byte>(input);
byte[] output = queue.DequeueAll();
Assert.AreEqual(input, output);
}
示例2: QueueExtensions_DequeueAllReturnsEmptyListIfQueueIsEmpty
public void QueueExtensions_DequeueAllReturnsEmptyListIfQueueIsEmpty()
{
Queue<int> queue = new Queue<int>();
var items = queue.DequeueAll();
Assert.IsNotNull(items);
Assert.AreEqual(0, items.Count());
}
示例3: QueueExtensions_Enqueue
public void QueueExtensions_Enqueue()
{
var input = new byte[] { 0x9A, 0xBC, 0xDE, 0xF0 };
var queue = new Queue<byte>();
queue.Enqueue(input);
Assert.AreEqual(input.Length, queue.Count);
Assert.AreEqual(input, queue.DequeueAll());
}
示例4: QueueExtensions_DequeueAll
public void QueueExtensions_DequeueAll()
{
Queue<int> queue = new Queue<int>();
queue.Enqueue(1);
queue.Enqueue(2);
queue.Enqueue(3);
var items = queue.DequeueAll();
Assert.IsNotNull(items);
Assert.AreEqual(3, items.Count());
}
示例5: Parse
public static CommandCompleteEvent Parse(EventCode code, Queue<byte> data)
{
if (data.Count < 4)
return null;
return new CommandCompleteEvent
{
Code = code,
NumberOfCommandsAllowedToSend = data.Dequeue(),
CommandOpcode = (ushort)(data.Dequeue() + (data.Dequeue() << 8)),
CommandParameterDataLength = data.Dequeue(),
ResultData = data.DequeueAll()
};
}
示例6: TestAsyncExecuter
public void TestAsyncExecuter()
{
var ints = new Queue<int>();
var actions = new Queue<Action>();
for(var i = 0; i < 10; ++i)
{
actions.Enqueue(new EnqueueHelper(ints, i).Run);
}
var threadQueue = new Regulus.Utility.AsyncExecuter(actions.DequeueAll());
threadQueue.WaitDone();
var values = ints.DequeueAll();
Assert.AreEqual(0, values[0]);
Assert.AreEqual(1, values[1]);
Assert.AreEqual(2, values[2]);
Assert.AreEqual(3, values[3]);
Assert.AreEqual(4, values[4]);
Assert.AreEqual(5, values[5]);
Assert.AreEqual(6, values[6]);
Assert.AreEqual(7, values[7]);
Assert.AreEqual(8, values[8]);
Assert.AreEqual(9, values[9]);
threadQueue.Push(new EnqueueHelper(ints, 10).Run);
threadQueue.Push(new EnqueueHelper(ints, 11).Run);
threadQueue.Push(new EnqueueHelper(ints, 12).Run);
threadQueue.WaitDone();
var values2 = ints.DequeueAll();
Assert.AreEqual(10, values2[0]);
Assert.AreEqual(11, values2[1]);
Assert.AreEqual(12, values2[2]);
}