本文整理汇总了C#中LinkedStack类的典型用法代码示例。如果您正苦于以下问题:C# LinkedStack类的具体用法?C# LinkedStack怎么用?C# LinkedStack使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LinkedStack类属于命名空间,在下文中一共展示了LinkedStack类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:nok32,项目名称:SoftUni,代码行数:7,代码来源:LinkedStackTests.cs
示例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);
}
开发者ID:AsenTahchiyski,项目名称:SoftUni,代码行数:26,代码来源:Program.cs
示例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);
}
}
开发者ID:psha-,项目名称:softuni-datastruct,代码行数:25,代码来源:UnitTestsLinkedStacks.cs
示例4: ToArrayOnEmptyStackShouldReturnEmptyArray
public void ToArrayOnEmptyStackShouldReturnEmptyArray()
{
LinkedStack<int> stack = new LinkedStack<int>();
var resultArray = stack.ToArray();
Assert.AreEqual(0, resultArray.Length);
}
开发者ID:tockata,项目名称:Data-Structures,代码行数:7,代码来源:LinkedStackTests.cs
示例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);
}
}
开发者ID:kosio197,项目名称:SoftUni_DataStructures,代码行数:25,代码来源:TestLincedStack.cs
示例6: EmptyLinkedStackToArray
public void EmptyLinkedStackToArray()
{
var linkedStack = new LinkedStack<DateTime>();
var testArr = new DateTime[0];
CollectionAssert.AreEqual(testArr, linkedStack.ToArray());
}
开发者ID:Aleksandyr,项目名称:Software-University,代码行数:7,代码来源:LinkedStackTests.cs
示例7: EmptyArraysShouldBeEqual
public void EmptyArraysShouldBeEqual()
{
var stack = new LinkedStack<DateTime>();
var array = new DateTime[] { };
CollectionAssert.AreEqual(array, stack.ToArray());
}
开发者ID:plamenyovchev,项目名称:DataStructures,代码行数:7,代码来源:LinkedStackTests.cs
示例8: 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
示例9: 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
示例10: 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
示例11: To_Array_Empty
public void To_Array_Empty()
{
var dates = new LinkedStack<DateTime>();
var arrTest = new DateTime[0];
CollectionAssert.AreEqual(arrTest, dates.ToArray());
}
开发者ID:Petar-Ivanov256,项目名称:DataStuctures_HomeWorks,代码行数:7,代码来源:LinkedStackTests.cs
示例12: 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
示例13: CheckCountAfterOnePush_ShouldBeOne
public void CheckCountAfterOnePush_ShouldBeOne()
{
var linkedStack = new LinkedStack<int>();
linkedStack.Push(1);
Assert.AreEqual(1, linkedStack.Count);
}
开发者ID:zerefel,项目名称:Data-Structures-And-Algorithms,代码行数:7,代码来源:LinkedStackPushPop.cs
示例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);
}
开发者ID:anichalakova,项目名称:DataStructuresHWs,代码行数:26,代码来源:UnitTestsLinkedStack.cs
示例15: PushPopElement
public void PushPopElement()
{
LinkedStack<int> testStack = new LinkedStack<int>();
Assert.AreEqual(0,testStack.Count);
testStack.Push(1);
Assert.AreEqual(1,testStack.Count);
}
开发者ID:EBojilova,项目名称:SoftUni-3,代码行数:7,代码来源:LinkedStackTests.cs
示例16: TestEmptyStackToArray_ShouldReturnEmptyArray
public void TestEmptyStackToArray_ShouldReturnEmptyArray()
{
var stack = new LinkedStack<DateTime>();
var array = stack.ToArray();
var expected = new DateTime[0];
CollectionAssert.AreEqual(expected, array);
}
开发者ID:AsenTahchiyski,项目名称:SoftUni,代码行数:7,代码来源:UnitTest1.cs
示例17: LinkedStack_PushPopManyChunks_ShouldWorkCorrectly
public void LinkedStack_PushPopManyChunks_ShouldWorkCorrectly()
{
// Arrange
var stack = new LinkedStack<int>();
int chunks = 100;
// Act & Assert in a loop
int value = 1;
for (int i = 0; i < chunks; i++)
{
Assert.AreEqual(0, stack.Count);
var chunkSize = i + 1;
for (int counter = 0; counter < chunkSize; counter++)
{
Assert.AreEqual(value - 1, stack.Count);
stack.Push(value);
Assert.AreEqual(value, stack.Count);
value++;
}
for (int counter = 0; counter < chunkSize; counter++)
{
value--;
Assert.AreEqual(value, stack.Count);
stack.Pop();
Assert.AreEqual(value - 1, stack.Count);
}
Assert.AreEqual(0, stack.Count);
}
}
开发者ID:pkanev,项目名称:Data.Structures,代码行数:29,代码来源:UnitTestsLinkedStack.cs
示例18: TestEmptyStackToArray
public void TestEmptyStackToArray()
{
var stack = new LinkedStack<DateTime>();
DateTime[] array = stack.ToArray();
Assert.AreEqual(0, array.Length);
}
开发者ID:bobosam,项目名称:DataStructures,代码行数:7,代码来源:LinkedStackTests.cs
示例19: 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);
}
开发者ID:tockata,项目名称:Data-Structures,代码行数:8,代码来源:LinkedStackTests.cs
示例20: Create_EmptyLinkedStack_ShouldGetCountZero
public void Create_EmptyLinkedStack_ShouldGetCountZero()
{
// Arrange
var emptyStack = new LinkedStack<int>();
// Assert
Assert.AreEqual(0, emptyStack.Count);
}
开发者ID:milen-vm,项目名称:Data-Structures,代码行数:8,代码来源:UnitTestLinkedStack.cs
注:本文中的LinkedStack类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论