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


C# SinglyLinkedList.Remove方法代码示例

本文整理汇总了C#中SinglyLinkedList.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# SinglyLinkedList.Remove方法的具体用法?C# SinglyLinkedList.Remove怎么用?C# SinglyLinkedList.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SinglyLinkedList的用法示例。


在下文中一共展示了SinglyLinkedList.Remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        public static void Main()
        {
            var list = new SinglyLinkedList<int>();

            for (int i = 0; i < 10; i++)
            {
                list.Add(i);
                Console.Write("Added " + i);
                Console.WriteLine(" Count -> " + list.Count);
            }

            Console.WriteLine("Items:");
            foreach (var item in list)
            {
                Console.Write(item + " ");
            }

            Console.WriteLine();

            int index = 0;
            for (int i = 0; i < 10; i++)
            {
                list.Remove(i - index++);
                Console.Write("Remmoved " + i);
                Console.WriteLine(" Count -> " + list.Count);
            }

            Console.WriteLine("Items:");
            foreach (var item in list)
            {
                Console.Write(item + " ");
            }
        }
开发者ID:Nezhdetov,项目名称:Software-University,代码行数:33,代码来源:Program.cs

示例2: Main

        private static void Main()
        {
            var list = new SinglyLinkedList<int>();

            list.ForEach(Console.WriteLine);
            Console.WriteLine("--------------------");

            list.Add(5);
            list.Add(3);
            list.Add(2);
            list.Add(10, 1);
            list.Add(5);
            list.Add(99);
            Console.WriteLine("Count = {0}", list.Count);

            list.ForEach(Console.WriteLine);
            Console.WriteLine("--------------------");

            list.Remove(1);
            Console.WriteLine("Count = {0}", list.Count);
            list.ForEach(Console.WriteLine);
            Console.WriteLine("--------------------");

            Console.WriteLine(list.FirstIndexOf(5));
            Console.WriteLine("--------------------");

            Console.WriteLine(list.LastIndexOf(5));
        }
开发者ID:anichalakova,项目名称:DataStructuresHWs,代码行数:28,代码来源:Program.cs

示例3: 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);
        }
    }
开发者ID:bobosam,项目名称:DataStructures,代码行数:28,代码来源:SinglyLinkedListTEst.cs

示例4: Main

    static void Main()
    {
        var myList = new SinglyLinkedList<int>();
        myList.Add(1);
        myList.Add(2);
        myList.Add(3);
        myList.Add(2);
        myList.Add(1);

        Console.WriteLine(string.Join(" ", myList));
        Console.WriteLine(myList.FirstIndexOf(2));
        myList.Remove(4);
        Console.WriteLine(string.Join(" ", myList));
        Console.WriteLine(myList.Count);
    }
开发者ID:vangelov-i,项目名称:Fundamentals,代码行数:15,代码来源:Program.cs

示例5: RemoveItemFromEmptySinglyLinkedListCollection

        public void RemoveItemFromEmptySinglyLinkedListCollection()
        {
            SinglyLinkedList<int> sll = new SinglyLinkedList<int>();

            Assert.IsFalse(sll.Remove(10));
        }
开发者ID:robertrancz,项目名称:dsa,代码行数:6,代码来源:SinglyLinkedListTest.cs

示例6: 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

示例7: RemoveTest

 public void RemoveTest()
 {
     var list = new SinglyLinkedList<int> { 1, 0, -1, 1 };
     Assert.IsTrue(list.Remove(1));
     Assert.AreEqual(3, list.Count, "Did not remove the item");
 }
开发者ID:joshimoo,项目名称:JamLib,代码行数:6,代码来源:SinglyLinkedListTests.cs

示例8: Remove_value_from_single_item_list

        public void Remove_value_from_single_item_list()
        {
            var list = new SinglyLinkedList<int>(new ListNode<int>(12));

            list.Remove(12);

            Assert.That(list.Length, Is.EqualTo(0));
            Assert.Null(list.Head);
        }
开发者ID:ChrisAnn,项目名称:BackToBasics,代码行数:9,代码来源:SinglyLinkedListTests.cs

示例9: RemoveWithNoMatchTest

        public void RemoveWithNoMatchTest()
        {
            SinglyLinkedList<int> sll = new SinglyLinkedList<int> {20, 30, 50};

            Assert.AreEqual(3, sll.Count);
            Assert.IsFalse(sll.Remove(110));
        }
开发者ID:robertrancz,项目名称:dsa,代码行数:7,代码来源:SinglyLinkedListTest.cs

示例10: 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"));
        }
开发者ID:Bpoe,项目名称:Data-Structures-and-Algorithms,代码行数:11,代码来源:SinglyLinkedListTests.cs

示例11: Remove_ValidIndex_ShouldRemove

        public void Remove_ValidIndex_ShouldRemove()
        {
            const int N = 100;
            var list = new SinglyLinkedList<int>();

            for (int i = 0; i < N; i++)
            {
                list.Add(i);
                list.Remove(0);
            }

            Assert.AreEqual(0, list.Count);
        }
开发者ID:Nezhdetov,项目名称:Software-University,代码行数:13,代码来源:UnitTestsLinkedList.cs

示例12: RemoveOnlyNodeInListTest

        public void RemoveOnlyNodeInListTest()
        {
            SinglyLinkedList<int> actual = new SinglyLinkedList<int> { 12 };

            actual.Remove(12);

            Assert.IsNull(actual.Head);
            Assert.IsNull(actual.Tail);
        }
开发者ID:robertrancz,项目名称:dsa,代码行数:9,代码来源:SinglyLinkedListTest.cs

示例13: Remove_ValidIndex_ShouldDecrementCount

        public void Remove_ValidIndex_ShouldDecrementCount()
        {
            const int N = 100;
            var list = new SinglyLinkedList<int>();

            for (int i = 0; i < N; i++)
            {
                list.Add(i);
            }

            list.Remove(0);
            list.Remove(1);
            list.Remove(2);

            Assert.AreEqual(N - 3, list.Count);
        }
开发者ID:Nezhdetov,项目名称:Software-University,代码行数:16,代码来源:UnitTestsLinkedList.cs

示例14: Remove_InvalidIndex_ShouldThrow

        public void Remove_InvalidIndex_ShouldThrow()
        {
            var list = new SinglyLinkedList<int>();

            list.Remove(0);
        }
开发者ID:Nezhdetov,项目名称:Software-University,代码行数:6,代码来源:UnitTestsLinkedList.cs

示例15: RemoveWithNoMatchTest

 public void RemoveWithNoMatchTest([PexAssumeUnderTest]List<string> list, string inputval)
 {
     PexAssume.IsFalse(list.Contains(inputval));
     SinglyLinkedList<string> sll = new SinglyLinkedList<string> (list);
     PexAssert.AreEqual(list.Count, sll.Count);
     PexAssert.IsFalse(sll.Remove(inputval));
 }
开发者ID:taoxiease,项目名称:asegrp,代码行数:7,代码来源:SinglyLinkedListTest.cs


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