本文整理汇总了C#中SinglyLinkedList.Find方法的典型用法代码示例。如果您正苦于以下问题:C# SinglyLinkedList.Find方法的具体用法?C# SinglyLinkedList.Find怎么用?C# SinglyLinkedList.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SinglyLinkedList
的用法示例。
在下文中一共展示了SinglyLinkedList.Find方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestFind
public void TestFind()
{
var expected = new int[4] { 0, 1, 2, 3 };
var list = new SinglyLinkedList<int>(expected);
var actual = list.Find(2);
Assert.IsNotNull(actual);
Assert.AreEqual(2, actual.Value);
}
示例2: Does_not_find_value_which_is_not_in_the_list
public void Does_not_find_value_which_is_not_in_the_list()
{
var expectedNode = new ListNode<int>(42);
var head = new ListNode<int>(12) { Next = new ListNode<int>(77) { Next = expectedNode } };
var list = new SinglyLinkedList<int>(head);
Assert.Null(list.Find(99));
}
示例3: Does_not_remove_node_when_matching_value_not_in_list
public void Does_not_remove_node_when_matching_value_not_in_list()
{
var head = new ListNode<int>(12) { Next = new ListNode<int>(42) { Next = new ListNode<int>(77) } };
var list = new SinglyLinkedList<int>(head);
list.Remove(new ListNode<int>(99));
Assert.That(list.Length, Is.EqualTo(3));
Assert.Null(list.Find(99));
}
示例4: Remove_value_from_head_of_multiple_items_list
public void Remove_value_from_head_of_multiple_items_list()
{
var head = new ListNode<int>(12) { Next = new ListNode<int>(42) { Next = new ListNode<int>(77) } };
var list = new SinglyLinkedList<int>(head);
list.Remove(head.Value);
Assert.That(list.Length, Is.EqualTo(2));
Assert.Null(list.Find(head.Value));
}
示例5: Remove_value_from_middle_of_multiple_items_list
public void Remove_value_from_middle_of_multiple_items_list()
{
var list = new SinglyLinkedList<int>(new ListNode<int>(12) { Next = new ListNode<int>(42) { Next = new ListNode<int>(77) } });
list.Remove(42);
Assert.That(list.Length, Is.EqualTo(2));
Assert.Null(list.Find(42));
}
示例6: Remove_single_node_with_matching_value_from_middle_of_multiple_items_list
public void Remove_single_node_with_matching_value_from_middle_of_multiple_items_list()
{
var nodeToRemove = new ListNode<int>(42) { Next = new ListNode<int>(77) };
var head = new ListNode<int>(12) { Next = nodeToRemove };
var list = new SinglyLinkedList<int>(head);
list.Remove(nodeToRemove);
Assert.That(list.Length, Is.EqualTo(2));
Assert.Null(list.Find(nodeToRemove.Value));
}
示例7: Finds_node_with_given_value
public void Finds_node_with_given_value()
{
var expectedNode = new ListNode<int>(42);
var head = new ListNode<int>(12) { Next = new ListNode<int>(77) {Next = expectedNode} };
var list = new SinglyLinkedList<int>(head);
Assert.That(list.Find(42), Is.EqualTo(expectedNode));
}
示例8: Find_should_return_null_when_does_not_exist
public void Find_should_return_null_when_does_not_exist()
{
ISinglyLinkedList<int> list = new SinglyLinkedList<int>(new[] { 1, 2, 3 });
var item = list.Find(4);
Assert.That(item, Is.Null);
}
示例9: Find_should_return_LinkedItem_when_exist
public void Find_should_return_LinkedItem_when_exist()
{
ISinglyLinkedList<int> list = new SinglyLinkedList<int>(new[] { 1, 2, 3 });
var item = list.Find(3);
Assert.That(item, Is.Not.Null);
Assert.That(item.Data, Is.EqualTo(3));
Assert.That(item, Is.EqualTo(list.Tail));
}
示例10: FindTest
public void FindTest()
{
var list = new SinglyLinkedList<int> { 1, 0, -1 };
Assert.IsNotNull(list.Find(0), "The list does not contain the item");
}