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


C# LinkedStack.Peek方法代码示例

本文整理汇总了C#中LinkedStack.Peek方法的典型用法代码示例。如果您正苦于以下问题:C# LinkedStack.Peek方法的具体用法?C# LinkedStack.Peek怎么用?C# LinkedStack.Peek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LinkedStack的用法示例。


在下文中一共展示了LinkedStack.Peek方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestPeakAfterPushPopElement

        public void TestPeakAfterPushPopElement()
        {
            var stack = new LinkedStack<int>();

            stack.Push(10);
            stack.Push(20);
            Assert.AreEqual(20, stack.Peek());
            stack.Pop();
            Assert.AreEqual(10, stack.Peek());
        }
开发者ID:bobosam,项目名称:DataStructures,代码行数:10,代码来源:LinkedStackTests.cs

示例2: Test02StackPeek

        public void Test02StackPeek()
        {
            var s = new LinkedStack<int>();
            s.Push(3);
            s.Push(1);
            s.Push(8);
            s.Push(5);

            Assert.AreEqual(5, s.Peek());
            s.Pop();
            Assert.AreEqual(8, s.Peek());
            s.Pop();
            Assert.AreEqual(1, s.Peek());
        }
开发者ID:tongko,项目名称:LargeFileEditor,代码行数:14,代码来源:LinkedStackTests.cs

示例3: PushingElementShouldContainElement

        public void PushingElementShouldContainElement()
        {
            var stack = new LinkedStack<int>();

            stack.Push(6);

            Assert.IsTrue(stack.Peek() == 6, "The stack must contain 6.");
            Assert.IsTrue(stack.Count == 1, "The stack count must be 1.");
        }
开发者ID:alex687,项目名称:SoftUni-Homeworks,代码行数:9,代码来源:LinkedStackTests.cs

示例4: Main

        public static void Main(string[] args)
        {
            var stack = new LinkedStack<int>();

            stack.Push(1);
            stack.Push(2);
            stack.Push(3);
            stack.Push(4);

            stack.Pop();
            var array = stack.ToArray();
            Console.WriteLine(stack.Peek());
        }
开发者ID:alex687,项目名称:SoftUni-Homeworks,代码行数:13,代码来源:Program.cs

示例5: PushPeekManyElementsShouldSetCountCorrectlyAndReturnCorrectElement

        public void PushPeekManyElementsShouldSetCountCorrectlyAndReturnCorrectElement()
        {
            LinkedStack<string> stack = new LinkedStack<string>();

            Assert.AreEqual(0, stack.Count, "Count for newly created stack is not correct.");

            for (int i = 0; i < 1000; i++)
            {
                stack.Push(i.ToString());
            }

            for (int i = 1000; i >= 0; i--)
            {
                Assert.AreEqual("999", stack.Peek(), "Peeked element is not correct.");
                Assert.AreEqual(1000, stack.Count, "Count after element peeking is not correct");
            }
        }
开发者ID:ttitto,项目名称:DataStructuresAndAlgorithms,代码行数:17,代码来源:LinkedStackTests.cs

示例6: PeekOnEmptyStackShouldThrowException

 public void PeekOnEmptyStackShouldThrowException()
 {
     LinkedStack<int> stack = new LinkedStack<int>();
     stack.Peek();
 }
开发者ID:ttitto,项目名称:DataStructuresAndAlgorithms,代码行数:5,代码来源:LinkedStackTests.cs

示例7: PeekFromEmptyStackShotuldThrowException

        public void PeekFromEmptyStackShotuldThrowException()
        {
            var stack = new LinkedStack<int>();

            stack.Peek();
        }
开发者ID:alex687,项目名称:SoftUni-Homeworks,代码行数:6,代码来源:LinkedStackTests.cs


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