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


C# LinkedStack.Push方法代码示例

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


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

示例1: PopTest

 [TestMethod] // получение последнего элемента
 public void PopTest()
 {
     LinkedStack<object> data = new LinkedStack<object>();
     data.Push(8);
     data.Push(6);
     data.Pop();
 }
开发者ID:steeparts,项目名称:Muftiyev_Arthur_06,代码行数:8,代码来源:LinkedStack.cs

示例2: CloneTest

 [TestMethod] // ICloneable
 public void CloneTest()
 {
     LinkedStack<object> data = new LinkedStack<object>();
     data.Push(8);
     data.Push(10);
     data.Clone();
 }
开发者ID:steeparts,项目名称:Muftiyev_Arthur_06,代码行数:8,代码来源:LinkedStack.cs

示例3: EnumerableTest

 [TestMethod] // IEnumerable
 public void EnumerableTest()
 {
     LinkedStack<object> data = new LinkedStack<object>();
     data.Push(8);
     data.Push(10);
     data.GetEnumerator();
 }
开发者ID:steeparts,项目名称:Muftiyev_Arthur_06,代码行数:8,代码来源:LinkedStack.cs

示例4: DisposeTest

 [TestMethod] //IDisposable
 public void DisposeTest()
 {
     LinkedStack<object> data = new LinkedStack<object>();
     data.Push(8);
     data.Push(14);
     data.Dispose();
 }
开发者ID:steeparts,项目名称:Muftiyev_Arthur_06,代码行数:8,代码来源:LinkedStack.cs

示例5: PushAndPopWithInitialCapacity1ShouldWorkCorrectly

        public void PushAndPopWithInitialCapacity1ShouldWorkCorrectly()
        {
            //Arrange
            var stack = new LinkedStack<int>();
            //Assert
            Assert.AreEqual(0, stack.Count);

            //Act
            stack.Push(1);
            //Assert
            Assert.AreEqual(1, stack.Count);
            //Act
            stack.Push(2);
            //Assert
            Assert.AreEqual(2, stack.Count);
            //Act
            var element = stack.Pop();
            //Assert
            Assert.AreEqual(2, element);
            Assert.AreEqual(1, stack.Count);
            //Act
            element = stack.Pop();
            //Assert
            Assert.AreEqual(1, element);
            Assert.AreEqual(0, stack.Count);
        }
开发者ID:anichalakova,项目名称:DataStructuresHWs,代码行数:26,代码来源:UnitTestsLinkedStack.cs

示例6: Push_Pop_Two

        public void Push_Pop_Two()
        {
            var ints = new LinkedStack<int> ();
            Assert.AreEqual (0, ints.Count);

            int element1 = 1;
            ints.Push (element1);
            Assert.AreEqual (1, ints.Count);

            int element2 = 2;
            ints.Push (element2);
            Assert.AreEqual (2, ints.Count);

            {
                int poppedEl = ints.Pop ();
                Assert.AreEqual (poppedEl, element2);
                Assert.AreEqual (1, ints.Count);
            }

            {
                int poppedEl = ints.Pop ();
                Assert.AreEqual (poppedEl, element1);
                Assert.AreEqual (0, ints.Count);
            }
        }
开发者ID:psha-,项目名称:softuni-datastruct,代码行数:25,代码来源:UnitTestsLinkedStacks.cs

示例7: Main

 static void Main()
 {
     LinkedStack<int> numbers = new LinkedStack<int>();
     numbers.Push(2);
     numbers.Push(3);
     numbers.Push(-4);
     numbers.ToArray();
 }
开发者ID:simooo93,项目名称:SoftUni-Homeworks,代码行数:8,代码来源:LinkedStackTest.cs

示例8: TestCountAfterPushing

 public void TestCountAfterPushing()
 {
     var stack = new LinkedStack<int>();
     stack.Push(1);
     stack.Push(2);
     stack.Push(3);
     Assert.AreEqual(3, stack.Count);
 }
开发者ID:bobosam,项目名称:DataStructures,代码行数:8,代码来源:LinkedStackTests.cs

示例9: CreateStack_PeakTopElement_ShouldWorkCorrectly

        public void CreateStack_PeakTopElement_ShouldWorkCorrectly()
        {
            var stack = new LinkedStack<int>();
            stack.Push(2);
            stack.Push(6);

            Assert.AreEqual(6, stack.Peak());
        }
开发者ID:nok32,项目名称:SoftUni,代码行数:8,代码来源:LinkedStackTests.cs

示例10: array

        public void array()
        {
            LinkedStack<int> testArray = new LinkedStack<int>();
            testArray.Push(3);
            testArray.Push(5);
            testArray.Push(-2);
            testArray.Push(7);

            CollectionAssert.AreEqual(new int[] { 7, -2, 5, 3 }, testArray.ToArray());
        }
开发者ID:kosio197,项目名称:SoftUni_DataStructures,代码行数:10,代码来源:TestLincedStack.cs

示例11: PopElementFromLinkedStackShouldReturnTheLastElement

        public void PopElementFromLinkedStackShouldReturnTheLastElement()
        {
            LinkedStack<int> arrayStack = new LinkedStack<int>();
            arrayStack.Push(1);
            arrayStack.Push(2);
            arrayStack.Push(3);
            var lastElement = arrayStack.Pop();

            Assert.AreEqual(3, lastElement);
        }
开发者ID:rozay,项目名称:Data-Structures,代码行数:10,代码来源:LinkedStackTests.cs

示例12: CreateStack_PopSingleElement_ShouldWorkCorrectly

        public void CreateStack_PopSingleElement_ShouldWorkCorrectly()
        {
            var stack = new LinkedStack<int>();
            stack.Push(2);
            stack.Push(6);
            stack.Push(1);

            Assert.AreEqual(1, stack.Pop());
            Assert.AreEqual(2, stack.Count);
        }
开发者ID:nok32,项目名称:SoftUni,代码行数:10,代码来源:LinkedStackTests.cs

示例13: Main

 static void Main()
 {
     var linkedStack = new LinkedStack<int>();
     linkedStack.Push(7);
     linkedStack.Push(8);
     linkedStack.Push(9);
     Console.WriteLine(string.Join(" ", linkedStack.ToArray()));
     Console.WriteLine("Popped element: " + linkedStack.Pop().ToString());
     Console.WriteLine(string.Join(" ", linkedStack.ToArray()));
 }
开发者ID:anichalakova,项目名称:DataStructuresHWs,代码行数:10,代码来源:Program.cs

示例14: 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

示例15: To_Array

 public void To_Array()
 {
     var nums = new LinkedStack<int>();
     nums.Push(3);
     nums.Push(5);
     nums.Push(-2);
     nums.Push(7);
     int[] arrTest = { 7, -2, 5, 3 };
     CollectionAssert.AreEqual(arrTest, nums.ToArray());
 }
开发者ID:Petar-Ivanov256,项目名称:DataStuctures_HomeWorks,代码行数:10,代码来源:LinkedStackTests.cs


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