当前位置: 首页>>代码示例>>C#>>正文


C# SinglyLinkedList.Find方法代码示例

本文整理汇总了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);
        }
开发者ID:Bpoe,项目名称:Data-Structures-and-Algorithms,代码行数:10,代码来源:SinglyLinkedListTests.cs

示例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));
        }
开发者ID:ChrisAnn,项目名称:BackToBasics,代码行数:8,代码来源:SinglyLinkedListTests.cs

示例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));
        }
开发者ID:ChrisAnn,项目名称:BackToBasics,代码行数:10,代码来源:SinglyLinkedListTests.cs

示例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));
        }
开发者ID:ChrisAnn,项目名称:BackToBasics,代码行数:10,代码来源:SinglyLinkedListTests.cs

示例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));
        }
开发者ID:ChrisAnn,项目名称:BackToBasics,代码行数:9,代码来源:SinglyLinkedListTests.cs

示例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));
        }
开发者ID:ChrisAnn,项目名称:BackToBasics,代码行数:11,代码来源:SinglyLinkedListTests.cs

示例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));
        }
开发者ID:ChrisAnn,项目名称:BackToBasics,代码行数:8,代码来源:SinglyLinkedListTests.cs

示例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);
 }
开发者ID:evilz,项目名称:algorithm-datastructure,代码行数:6,代码来源:SimpleLinkedListTests.cs

示例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));
 }
开发者ID:evilz,项目名称:algorithm-datastructure,代码行数:8,代码来源:SimpleLinkedListTests.cs

示例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");
 }
开发者ID:joshimoo,项目名称:JamLib,代码行数:5,代码来源:SinglyLinkedListTests.cs


注:本文中的SinglyLinkedList.Find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。