本文整理汇总了C#中Deque.PopLast方法的典型用法代码示例。如果您正苦于以下问题:C# Deque.PopLast方法的具体用法?C# Deque.PopLast怎么用?C# Deque.PopLast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Deque
的用法示例。
在下文中一共展示了Deque.PopLast方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
internal static void Main()
{
Deque<int> deque = new Deque<int>();
deque.PushFirst(3);
deque.PushFirst(5);
deque.PushFirst(7);
deque.PushLast(10);
deque.PushLast(13);
//The order of elements in Deque is: 7, 5, 3, 10, 13
//This will write on console first element without removing it from Deque -> 7
Console.WriteLine("Peek first element: {0}", deque.PeekFirst());
//This will write on console last element without removing it from Deque -> 13
Console.WriteLine("Peek last element: {0}", deque.PeekLast());
//This will write on console first element and remove it from Deque -> 7 again
Console.WriteLine("Pop first element: {0}", deque.PopFirst());
//This will write on console first element and remove it from Deque -> 5 again
Console.WriteLine("Pop first element: {0}", deque.PopFirst());
//This will write on console last element and remove it from Deque -> 13 again
Console.WriteLine("Pop last element: {0}", deque.PopLast());
//In the deque now you have only two elements -> 3 and 10
}
示例2: Main
internal static void Main()
{
Deque<string> deque = new Deque<string>();
string peterName = "Peter";
deque.PushFirst(peterName);
deque.PushLast("Last element");
deque.PushFirst("Before Peter");
deque.PushLast("After last element");
//This will return 4
Console.WriteLine("Number of elements: {0}", deque.Count);
//This will return true, because "Peter" is in the deque
Console.WriteLine("If deque contains: {0}, -> {1}", peterName, deque.Contains(peterName));
//This will return first element without removing it.
Console.WriteLine(deque.PeekFirst());
//This will return last element and remove it.
Console.WriteLine(deque.PopLast());
}