本文整理汇总了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();
}
示例2: CloneTest
[TestMethod] // ICloneable
public void CloneTest()
{
LinkedStack<object> data = new LinkedStack<object>();
data.Push(8);
data.Push(10);
data.Clone();
}
示例3: EnumerableTest
[TestMethod] // IEnumerable
public void EnumerableTest()
{
LinkedStack<object> data = new LinkedStack<object>();
data.Push(8);
data.Push(10);
data.GetEnumerator();
}
示例4: DisposeTest
[TestMethod] //IDisposable
public void DisposeTest()
{
LinkedStack<object> data = new LinkedStack<object>();
data.Push(8);
data.Push(14);
data.Dispose();
}
示例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);
}
示例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);
}
}
示例7: Main
static void Main()
{
LinkedStack<int> numbers = new LinkedStack<int>();
numbers.Push(2);
numbers.Push(3);
numbers.Push(-4);
numbers.ToArray();
}
示例8: TestCountAfterPushing
public void TestCountAfterPushing()
{
var stack = new LinkedStack<int>();
stack.Push(1);
stack.Push(2);
stack.Push(3);
Assert.AreEqual(3, stack.Count);
}
示例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());
}
示例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());
}
示例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);
}
示例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);
}
示例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()));
}
示例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());
}
示例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());
}