本文整理汇总了C#中LinkedStack类的典型用法代码示例。如果您正苦于以下问题:C# LinkedStack类的具体用法?C# LinkedStack怎么用?C# LinkedStack使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LinkedStack类属于命名空间,在下文中一共展示了LinkedStack类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateStack_PushSingleElement_ShouldWorkCorrectly
public void CreateStack_PushSingleElement_ShouldWorkCorrectly()
{
var stack = new LinkedStack<int>();
stack.Push(3);
Assert.AreEqual(3, stack.Peak());
Assert.AreEqual(1, stack.Count);
}
示例2: Main
static void Main()
{
var collection = new LinkedStack<int>();
collection.Push(1);
collection.Push(2);
collection.Push(3);
collection.Push(4);
collection.Push(5);
collection.Push(6);
collection.Push(7);
collection.Push(8);
collection.Push(9);
Console.WriteLine(collection.Pop());
Console.WriteLine(collection.Pop());
Console.WriteLine(collection.Pop());
Console.WriteLine(collection.Pop());
Console.WriteLine(collection.Pop());
Console.WriteLine("Count: " + collection.Count);
var array = collection.ToArray();
Console.WriteLine(string.Join(", ", array));
Console.WriteLine(collection.Pop());
Console.WriteLine("Count: " + collection.Count);
}
示例3: 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);
}
}
示例4: ToArrayOnEmptyStackShouldReturnEmptyArray
public void ToArrayOnEmptyStackShouldReturnEmptyArray()
{
LinkedStack<int> stack = new LinkedStack<int>();
var resultArray = stack.ToArray();
Assert.AreEqual(0, resultArray.Length);
}
示例5: 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);
}
}
示例6: EmptyLinkedStackToArray
public void EmptyLinkedStackToArray()
{
var linkedStack = new LinkedStack<DateTime>();
var testArr = new DateTime[0];
CollectionAssert.AreEqual(testArr, linkedStack.ToArray());
}
示例7: EmptyArraysShouldBeEqual
public void EmptyArraysShouldBeEqual()
{
var stack = new LinkedStack<DateTime>();
var array = new DateTime[] { };
CollectionAssert.AreEqual(array, stack.ToArray());
}
示例8: DisposeTest
[TestMethod] //IDisposable
public void DisposeTest()
{
LinkedStack<object> data = new LinkedStack<object>();
data.Push(8);
data.Push(14);
data.Dispose();
}
示例9: CloneTest
[TestMethod] // ICloneable
public void CloneTest()
{
LinkedStack<object> data = new LinkedStack<object>();
data.Push(8);
data.Push(10);
data.Clone();
}
示例10: EnumerableTest
[TestMethod] // IEnumerable
public void EnumerableTest()
{
LinkedStack<object> data = new LinkedStack<object>();
data.Push(8);
data.Push(10);
data.GetEnumerator();
}
示例11: To_Array_Empty
public void To_Array_Empty()
{
var dates = new LinkedStack<DateTime>();
var arrTest = new DateTime[0];
CollectionAssert.AreEqual(arrTest, dates.ToArray());
}
示例12: PopTest
[TestMethod] // получение последнего элемента
public void PopTest()
{
LinkedStack<object> data = new LinkedStack<object>();
data.Push(8);
data.Push(6);
data.Pop();
}
示例13: CheckCountAfterOnePush_ShouldBeOne
public void CheckCountAfterOnePush_ShouldBeOne()
{
var linkedStack = new LinkedStack<int>();
linkedStack.Push(1);
Assert.AreEqual(1, linkedStack.Count);
}
示例14: 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);
}
示例15: PushPopElement
public void PushPopElement()
{
LinkedStack<int> testStack = new LinkedStack<int>();
Assert.AreEqual(0,testStack.Count);
testStack.Push(1);
Assert.AreEqual(1,testStack.Count);
}