本文整理汇总了C#中LinkedStack.Pop方法的典型用法代码示例。如果您正苦于以下问题:C# LinkedStack.Pop方法的具体用法?C# LinkedStack.Pop怎么用?C# LinkedStack.Pop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinkedStack
的用法示例。
在下文中一共展示了LinkedStack.Pop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateStack_PushSomeElements_ShouldWorkCorrectly
public void CreateStack_PushSomeElements_ShouldWorkCorrectly()
{
var stack = new LinkedStack<int>();
stack.Push(2);
stack.Push(6);
Assert.AreEqual(2, stack.Count);
Assert.AreEqual(6, stack.Pop());
Assert.AreEqual(2, stack.Pop());
}
示例2: TestCountAfterPoping
public void TestCountAfterPoping()
{
var stack = new LinkedStack<int>();
stack.Push(1);
stack.Push(2);
stack.Push(3);
stack.Pop();
stack.Pop();
Assert.AreEqual(1, stack.Count);
}
示例3: Pop_Push
public void Pop_Push()
{
LinkedStack<int> testPop = new LinkedStack<int>();
Assert.AreEqual(0, testPop.Count);
testPop.Push(3);
Assert.AreEqual(1, testPop.Count);
testPop.Push(3);
Assert.AreEqual(2, testPop.Count);
Assert.AreEqual(3, testPop.Pop());
Assert.AreEqual(1, testPop.Count);
Assert.AreEqual(3, testPop.Pop());
Assert.AreEqual(0, testPop.Count);
}
示例4: Push_Pop_Elements
public void Push_Pop_Elements()
{
var nums = new LinkedStack<int>();
Assert.AreEqual(0, nums.Count);
nums.Push(15);
Assert.AreEqual(1, nums.Count);
nums.Push(12);
Assert.AreEqual(2, nums.Count);
Assert.AreEqual(12, nums.Pop());
Assert.AreEqual(1, nums.Count);
Assert.AreEqual(15, nums.Pop());
Assert.AreEqual(0, nums.Count);
}
示例5: 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());
}
示例6: TestPushPop_ShouldReturnCorrectResultsAndUpdateCounterProperly
public void TestPushPop_ShouldReturnCorrectResultsAndUpdateCounterProperly()
{
var stack = new LinkedStack<string>();
Assert.IsTrue(stack.Count == 0);
stack.Push("wow");
Assert.IsTrue(stack.Count == 1);
stack.Push("yeah");
Assert.IsTrue(stack.Count == 2);
var element = stack.Pop();
Assert.AreEqual("yeah", element);
Assert.IsTrue(stack.Count == 1);
element = stack.Pop();
Assert.AreEqual("wow", element);
Assert.IsTrue(stack.Count == 0);
}
示例7: 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);
}
}
示例8: Test01StackPushPop
public void Test01StackPushPop()
{
var s = new LinkedStack<int>();
s.Push(3);
s.Push(1);
s.Push(8);
s.Push(5);
Assert.AreEqual(4, s.Count);
Assert.AreEqual(5, s.Pop());
Assert.AreEqual(8, s.Pop());
Assert.AreEqual(1, s.Pop());
Assert.AreEqual(3, s.Pop());
Assert.AreEqual(0, s.Count);
Assert.AreEqual(0, s.Pop());
}
示例9: Test_Push_Pop
public void Test_Push_Pop()
{
LinkedStack<int> roo = new LinkedStack<int>();
Assert.AreEqual(0, roo.Count);
roo.Push(9);
Assert.AreEqual(1, roo.Count);
Assert.AreEqual(9, roo.Pop());
Assert.AreEqual(0, roo.Count);
LinkedStack<string> testPush = new LinkedStack<string>();
Assert.AreEqual(0, testPush.Count);
for (int i = 1; i <= 1000; i++)
{
testPush.Push("as" + i);
Assert.AreEqual(i, testPush.Count);
}
for (int i = 1000; i >= 1; i--)
{
Assert.AreEqual("as" + i, testPush.Pop());
Assert.AreEqual(i - 1, testPush.Count);
}
}
示例10: PopTest
[TestMethod] // получение последнего элемента
public void PopTest()
{
LinkedStack<object> data = new LinkedStack<object>();
data.Push(8);
data.Push(6);
data.Pop();
}
示例11: CheckCountAfterOnePop_ShouldBeZero
public void CheckCountAfterOnePop_ShouldBeZero()
{
var linkedStack = new LinkedStack<int>();
linkedStack.Push(1);
linkedStack.Pop();
Assert.AreEqual(0, linkedStack.Count);
}
示例12: CheckInitialCapacity_ShouldReturnCorrectElement
public void CheckInitialCapacity_ShouldReturnCorrectElement()
{
var linkedStack = new LinkedStack<int>();
linkedStack.Push(1);
Assert.AreEqual(1, linkedStack.Count);
linkedStack.Push(100);
Assert.AreEqual(2, linkedStack.Count);
linkedStack.Pop();
Assert.AreEqual(1, linkedStack.Count);
int element = linkedStack.Pop();
Assert.AreEqual(1, element);
Assert.AreEqual(0, linkedStack.Count);
}
示例13: Main
static void Main()
{
LinkedStack<int> linkedStack = new LinkedStack<int>();
linkedStack.Push(5);
linkedStack.Push(7);
linkedStack.Push(6);
Console.WriteLine(linkedStack.Pop());
Console.WriteLine(linkedStack.Pop());
linkedStack.Push(1);
linkedStack.Push(2);
Console.WriteLine(linkedStack.Pop());
Console.WriteLine(linkedStack.Pop());
}
示例14: Main
static void Main(string[] args)
{
LinkedStack<int> stack = new LinkedStack<int>();
stack.Push(1);
stack.Push(2);
stack.Push(3);
stack.Push(4);
stack.Push(5);
stack.Push(6);
stack.Push(7);
Console.WriteLine(stack.Count == 7);
Console.WriteLine();
while (stack.Count > 0)
{
Console.WriteLine(stack.Pop());
}
stack.Push(1);
stack.Push(2);
stack.Push(3);
stack.Push(4);
stack.Push(5);
stack.Push(6);
stack.Push(7);
stack.Push(8);
stack.Push(9);
stack.Push(10);
stack.Push(11);
stack.Push(12);
stack.Push(13);
stack.Push(14);
stack.Push(15);
stack.Push(16);
stack.Push(17);
stack.Push(18);
stack.Push(19);
stack.Push(20);
stack.Push(21);
Console.WriteLine(string.Join(", ", stack.ToArray()));
Console.WriteLine(stack.Count == 21);
while (stack.Count > 0)
{
Console.WriteLine(stack.Pop());
}
}
示例15: PopElementFromStackShouldReturnTheProperElementAndDecreaseCountWithOne
public void PopElementFromStackShouldReturnTheProperElementAndDecreaseCountWithOne()
{
LinkedStack<int> stackOfInts = new LinkedStack<int>();
stackOfInts.Push(5);
int poppedElement = stackOfInts.Pop();
Assert.AreEqual(5, poppedElement);
Assert.AreEqual(0, stackOfInts.Count);
}