本文整理汇总了C#中SinglyLinkedList.AddAfter方法的典型用法代码示例。如果您正苦于以下问题:C# SinglyLinkedList.AddAfter方法的具体用法?C# SinglyLinkedList.AddAfter怎么用?C# SinglyLinkedList.AddAfter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SinglyLinkedList
的用法示例。
在下文中一共展示了SinglyLinkedList.AddAfter方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddAfter_Should_change_tail_and_set_next_item_of_previous_item
public void AddAfter_Should_change_tail_and_set_next_item_of_previous_item()
{
ISinglyLinkedList<int> list = new SinglyLinkedList<int>(new [] {1});
var previous = list.Head;
list = list.AddAfter(2,previous);
Assert.That(list.Tail.Data,Is.EqualTo(2));
Assert.That(previous.Next, Is.EqualTo(list.Tail));
list = list.AddAfter(3, previous);
Assert.That(list.Tail.Data, Is.EqualTo(2));
Assert.That(previous.Next.Data, Is.EqualTo(3));
}
示例2: AddAfterTailTest
public void AddAfterTailTest()
{
SinglyLinkedList<int> sll = new SinglyLinkedList<int> {10, 20};
sll.AddAfter(sll.Tail, 30);
Assert.AreEqual(30, sll.Tail.Value);
Assert.AreEqual(30, sll.Head.Next.Next.Value);
Assert.AreEqual(3, sll.Count);
}
示例3: AddAfterMiddleNodeTest
public void AddAfterMiddleNodeTest()
{
SinglyLinkedList<int> sll = new SinglyLinkedList<int> {10, 20, 30};
sll.AddAfter(sll.Head.Next, 25);
Assert.AreEqual(25, sll.Head.Next.Next.Value);
Assert.AreEqual(30, sll.Head.Next.Next.Next.Value);
Assert.AreEqual(4, sll.Count);
}
示例4: AddAfterOnlyOneNodeInListTest
public void AddAfterOnlyOneNodeInListTest()
{
SinglyLinkedList<int> sll = new SinglyLinkedList<int> {10};
sll.AddAfter(sll.Head, 20);
Assert.AreEqual(20, sll.Tail.Value);
Assert.AreEqual(10, sll.Head.Value);
Assert.AreEqual(20, sll.Head.Next.Value);
Assert.AreEqual(2, sll.Count);
}
示例5: TestAddAfterNoPrevious
public void TestAddAfterNoPrevious()
{
var expected = new int[3] { 0, 1, 2 };
var list = new SinglyLinkedList<int>();
var node = list.AddLast(0);
list.AddLast(2);
list.AddAfter(node, 1);
Verify(expected, list);
}
示例6: TestAddAfterLast
public void TestAddAfterLast()
{
var expected = new int[3] { 0, 1, 2 };
var list = new SinglyLinkedList<int>();
list.AddLast(0);
list.AddLast(1);
var node = list.AddAfter(list.Last, 2);
Verify(expected, list);
Assert.AreSame(list.Last, node);
}
示例7: Adding_Should_increment_length
public void Adding_Should_increment_length()
{
ISinglyLinkedList<int> list = new SinglyLinkedList<int>(new[] { 1 });
Assert.That(list.Length, Is.EqualTo(1));
list = list.AddAfter(2,list.Tail);
Assert.That(list.Length, Is.EqualTo(2));
list = list.AddFirst(3);
Assert.That(list.Length, Is.EqualTo(3));
list = list.AddLast(4);
Assert.That(list.Length, Is.EqualTo(4));
}
示例8: AddAfterEmptyNullNodeTest
public void AddAfterEmptyNullNodeTest()
{
SinglyLinkedList<int> sll = new SinglyLinkedList<int>();
sll.AddAfter(sll.Head, 10);
}
示例9: AddAfterEmptyNullNodeTest
public void AddAfterEmptyNullNodeTest(int elementToAdd)
{
SinglyLinkedList<int> sll = new SinglyLinkedList<int>();
sll.AddAfter(sll.Head, elementToAdd);
}