本文整理汇总了C#中SinglyLinkedList.AddLast方法的典型用法代码示例。如果您正苦于以下问题:C# SinglyLinkedList.AddLast方法的具体用法?C# SinglyLinkedList.AddLast怎么用?C# SinglyLinkedList.AddLast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SinglyLinkedList
的用法示例。
在下文中一共展示了SinglyLinkedList.AddLast方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestAddAfterNoNext
public void TestAddAfterNoNext()
{
var expected = new int[3] { 0, 1, 2 };
var list = new SinglyLinkedList<int>();
list.AddLast(0);
var node = list.AddLast(1);
list.AddAfter(node, 2);
Verify(expected, list);
}
示例2: TestAddBefore
public void TestAddBefore()
{
var expected = new int[3] { 0, 1, 2 };
var list = new SinglyLinkedList<int>();
list.AddLast(0);
var node = list.AddLast(2);
list.AddBefore(node, 1);
Verify(expected, list);
}
示例3: 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);
}
示例4: BeginTestMethod
public void BeginTestMethod()
{
target = new SinglyLinkedList<int>();
Assert.AreEqual(target.Leng, 0);
target.Add(2);
target.Add(3, 1);
target.AddLast(5);
}
示例5: Main
static void Main()
{
SinglyLinkedList<int> list = new SinglyLinkedList<int>();
list.AddLast(1);
list.AddLast(2);
list.AddLast(3);
list.AddLast(4);
list.AddLast(5);
list.AddLast(6);
list.AddLast(3);
Console.WriteLine("FirstIndexOf(6): {0}", list.FirstIndexOf(6));
Console.WriteLine("FirstIndexOf(1): {0}", list.FirstIndexOf(1));
Console.WriteLine("FirstIndexOf(16): {0}", list.FirstIndexOf(16));
Console.WriteLine("LastIndexOf(3): {0}", list.LastIndexOf(3));
Console.WriteLine("LastIndexOf(30): {0}", list.LastIndexOf(30));
Console.WriteLine(list.Count);
list.Remove(0);
foreach (var item in list)
{
Console.WriteLine(item);
}
}
示例6: AddLast_Should_change_tail_and_set_next_of_previous_tail
public void AddLast_Should_change_tail_and_set_next_of_previous_tail()
{
ISinglyLinkedList<int> list = new SinglyLinkedList<int>(new[] { 1 });
var previous = list.Tail;
list = list.AddLast(2);
Assert.That(list.Tail.Data, Is.EqualTo(2));
Assert.That(previous.Next, Is.EqualTo(list.Tail));
}
示例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: TestRemoveValue
public void TestRemoveValue()
{
var list = new SinglyLinkedList<string>();
list.AddLast("Expected");
list.AddLast("Expected");
list.AddLast("Not expected");
list.AddLast("Expected");
Assert.IsTrue(list.Remove("Not expected"));
Assert.IsFalse(list.Contains("Not expected"));
}
示例9: TestRemoveNode
public void TestRemoveNode()
{
var list = new SinglyLinkedList<string>();
list.AddLast("Expected");
list.AddLast("Expected");
var notExpected = list.AddLast("Not expected");
list.AddLast("Expected");
list.Remove(notExpected);
bool found = false;
var current = list.First;
while (current != null && !found)
{
found = current == notExpected;
current = current.Next;
}
Assert.IsFalse(found);
}
示例10: TestRemoveLast
public void TestRemoveLast()
{
var expected = new int[2] { 0, 1 };
var list = new SinglyLinkedList<int>(expected);
list.AddLast(-1);
Assert.AreEqual(-1, list.Last.Value);
list.RemoveLast();
Verify(expected, list);
}
示例11: TestEnumerator
public void TestEnumerator()
{
var expected = new int[4] { 0, 1, 2, 3 };
var list = new SinglyLinkedList<int>();
list.AddLast(0);
list.AddLast(1);
list.AddLast(2);
list.AddLast(3);
Verify(expected, list);
}
示例12: TestAddLast
public void TestAddLast()
{
var expected = new int[2] { 0, 1 };
var list = new SinglyLinkedList<int>();
list.AddLast(0);
list.AddLast(1);
Verify(expected, list);
}
示例13: RemoveFirstTest
public void RemoveFirstTest()
{
SinglyLinkedList<int> sll = new SinglyLinkedList<int>();
sll.AddFirst(40);
sll.AddFirst(30);
sll.AddFirst(20);
sll.AddFirst(10);
sll.AddLast(50);
sll.RemoveFirst();
sll.RemoveFirst();
Assert.AreEqual(30, sll.Head.Value);
Assert.AreEqual(50, sll.Tail.Value);
Assert.AreEqual(3, sll.Count);
}