本文整理汇总了C#中SinglyLinkedList.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# SinglyLinkedList.Clear方法的具体用法?C# SinglyLinkedList.Clear怎么用?C# SinglyLinkedList.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SinglyLinkedList
的用法示例。
在下文中一共展示了SinglyLinkedList.Clear方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestClear
public void TestClear()
{
var expected = new int[4] { 0, 1, 2, 3 };
var list = new SinglyLinkedList<int>(expected);
list.Clear();
int x = 0;
foreach (int i in list)
{
x++;
}
Assert.AreEqual(0, list.Count);
Assert.AreEqual(0, x);
}
示例2: ClearTest
public void ClearTest()
{
SinglyLinkedList<int> sll = new SinglyLinkedList<int> {10, 20, 30};
sll.Clear();
Assert.AreEqual(0, sll.Count);
Assert.IsNull(sll.Head);
Assert.IsNull(sll.Tail);
}
示例3: Head_and_tail_and_should_be_null_when_list_is_clear
public void Head_and_tail_and_should_be_null_when_list_is_clear()
{
ISinglyLinkedList<int> list = new SinglyLinkedList<int>(new[] { 1, 2, 3 });
list = list.Clear();
Assert.That(list.Head, Is.Null);
Assert.That(list.Tail, Is.Null);
}
示例4: Length_should_be_0_when_list_is_clear
public void Length_should_be_0_when_list_is_clear()
{
ISinglyLinkedList<int> list = new SinglyLinkedList<int>(new[] { 1, 2, 3 });
list = list.Clear();
Assert.That(list.Length,Is.EqualTo(0));
}
示例5: ClearTest
public void ClearTest()
{
var list = new SinglyLinkedList<int> { 1, 0, -1 };
list.Clear();
Assert.AreEqual(0, list.Count, "List Size does not match");
}