本文整理汇总了C#中DoublyLinkedList.Add方法的典型用法代码示例。如果您正苦于以下问题:C# DoublyLinkedList.Add方法的具体用法?C# DoublyLinkedList.Add怎么用?C# DoublyLinkedList.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoublyLinkedList
的用法示例。
在下文中一共展示了DoublyLinkedList.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: should_return_the_node_if_the_value_exists
public void should_return_the_node_if_the_value_exists()
{
var list = new DoublyLinkedList<int>();
list.Add(5);
list.Add(3);
var node = list.Find(5);
Assert.That(node.Data.Equals(5), Is.True);
}
示例2: BeginTestMethod
public void BeginTestMethod()
{
target = new DoublyLinkedList<int>();
Assert.AreEqual(target.Leng, 0);
target.Add(2);
target.Add(3, 1);
target.AddLast(5);
}
示例3: Clear
public void Clear()
{
DoublyLinkedList<int> list = new DoublyLinkedList<int>();
list.Add(3);
list.Add(5);
list.Add(7);
list.Clear();
list.ShouldBeEmpty();
}
示例4: Contains
public void Contains()
{
DoublyLinkedList<int> list = new DoublyLinkedList<int>();
list.Add(3);
list.Add(5);
list.Add(7);
bool isTrue = list.Contains(3);
Assert.AreEqual(true, isTrue);
}
示例5: should_make_the_node_tail_of_the_list
public void should_make_the_node_tail_of_the_list()
{
var list = new DoublyLinkedList<int>();
list.Add(5);
list.Add(3);
Assert.That(list.Tail.Data.Equals(3), Is.True);
Assert.That(list.Head.Data.Equals(5), Is.True);
Assert.That(list.Head.Next.Data.Equals(3), Is.True);
}
示例6: CopyTo
public void CopyTo()
{
DoublyLinkedList<int> list = new DoublyLinkedList<int>();
int[] array = new int[3];
list.Add(3);
list.Add(5);
list.Add(7);
list.CopyTo(array, 0);
}
示例7: CopyToWithLessSpaceInTheArray
public void CopyToWithLessSpaceInTheArray()
{
DoublyLinkedList<int> list = new DoublyLinkedList<int>();
int[] array = new int[3];
list.Add(3);
list.Add(5);
list.Add(7);
list.CopyTo(array, 2);
}
示例8: ClassInitializer
public static void ClassInitializer(TestContext context)
{
head = new DoublyLinkedListNode<int>(-1);
doublyLinkedList= new DoublyLinkedList<int>(head);
doublyLinkedList.Add(4);
doublyLinkedList.Add(41);
doublyLinkedList.Add(54);
doublyLinkedList.Add(9);
}
示例9: TestDoublyLinkedListAdd
public void TestDoublyLinkedListAdd()
{
DoublyLinkedList<string> list = new DoublyLinkedList<string>();
list.Add("One");
list.Add("Two");
list.Add("Three");
Assert.AreEqual(3, list.Count);
}
示例10: TestDoublyLinkedListIndexer
public void TestDoublyLinkedListIndexer()
{
DoublyLinkedList<string> list = new DoublyLinkedList<string>();
list.Add("One");
list.Add("Two");
list.Add("Three");
list[0] = "Zero";
string[] array = new string[list.Count];
list.CopyTo(array);
Assert.AreEqual("Zero, Two, Three", string.Join(", ", array));
}
示例11: AddAtHead
public void AddAtHead()
{
DoublyLinkedList<int> list = new DoublyLinkedList<int>();
int[] array = new int[3];
list.Add(3);
list.ShouldContain(3);
list.Add(5);
list.ShouldContain(5);
list.Add(7);
list.ShouldContain(7);
list.CopyTo(array, 0);
}
示例12: TestDoublyLinkedListInsert_InsertInTheMiddle
public void TestDoublyLinkedListInsert_InsertInTheMiddle()
{
DoublyLinkedList<string> list = new DoublyLinkedList<string>();
list.Add("One");
list.Add("Two");
list.Add("Three");
list[0] = "Zero";
list.Insert(1, "Ten");
string[] array = new string[list.Count];
list.CopyTo(array);
Assert.AreEqual("Zero, Ten, Two, Three", string.Join(", ", array));
}
示例13: TestDoublyLinkedListForEach
public void TestDoublyLinkedListForEach()
{
DoublyLinkedList<string> list = new DoublyLinkedList<string>();
list.Add("One");
list.Add("Two");
list.Add("Three");
list[0] = "Zero";
string[] array = new string[list.Count];
int index = 0;
foreach (string item in list)
{
array[index] = item;
index++;
}
Assert.AreEqual("Zero, Two, Three", string.Join(", ", array));
}
示例14: should_delete_the_value_if_it_exists
public void should_delete_the_value_if_it_exists()
{
var list = new DoublyLinkedList<int>();
list.Add(5);
list.Add(2);
list.Add(3);
list.Delete(2);
Assert.That(list.Tail.Data.Equals(3), Is.True);
Assert.That(list.Head.Data.Equals(5), Is.True);
Assert.That(list.Head.Next.Data.Equals(3), Is.True);
list.Delete(5);
Assert.That(list.Tail.Data.Equals(3), Is.True);
Assert.That(list.Head.Data.Equals(3), Is.True);
list.Delete(3);
Assert.That(list.Tail, Is.Null);
Assert.That(list.Head, Is.Null);
}
示例15: CountTest
public void CountTest()
{
DoublyLinkedList<int> dll = new DoublyLinkedList<int> {10, 5};
dll.RemoveFirst();
dll.RemoveLast();
dll.Add(10);
dll.AddAfter(dll.Head, 30);
dll.AddBefore(dll.Head.Next, 20);
Assert.AreEqual(3, dll.Count);
}