当前位置: 首页>>代码示例>>C#>>正文


C# Deque.PopLast方法代码示例

本文整理汇总了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
        }
开发者ID:VyaraGGeorgieva,项目名称:TelerikAcademy,代码行数:27,代码来源:int+deque.cs

示例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());
        }
开发者ID:VyaraGGeorgieva,项目名称:TelerikAcademy,代码行数:21,代码来源:strings+deque.cs


注:本文中的Deque.PopLast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。