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


C# SinglyLinkedList.Add方法代码示例

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


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

示例1: BeginTestMethod

 public void BeginTestMethod()
 {
     target = new SinglyLinkedList<int>();
     Assert.AreEqual(target.Leng, 0);
     target.Add(2);
     target.Add(3, 1);
     target.AddLast(5);
 }
开发者ID:hirotk,项目名称:Algorithm,代码行数:8,代码来源:SinglyLinkedListTest.cs

示例2: TestSinglyLinkedListAdd

        public void TestSinglyLinkedListAdd()
        {
            SinglyLinkedList<string> list = new SinglyLinkedList<string>();
            list.Add("One");
            list.Add("Two");
            list.Add("Three");

            Assert.AreEqual(3, list.Count);
        }
开发者ID:Ivan-Dimitrov-bg,项目名称:.Net-framework,代码行数:9,代码来源:SinglyLinkedListTest.cs

示例3: LastIndexOf_ExistingItem_ShouldReturnCorrectIndex

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

            list.Add(1);
            list.Add(101);
            list.Add(1);
            list.Add(101);

            var index = list.LastIndexOf(1);
            Assert.AreEqual(2, index);
        }
开发者ID:Nezhdetov,项目名称:Software-University,代码行数:12,代码来源:UnitTestsLinkedList.cs

示例4: TestSinglyLinkedListIndexer

        public void TestSinglyLinkedListIndexer()
        {
            SinglyLinkedList<string> list = new SinglyLinkedList<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));
        }
开发者ID:Ivan-Dimitrov-bg,项目名称:.Net-framework,代码行数:12,代码来源:SinglyLinkedListTest.cs

示例5: FirstIndexOf_NonExistingItem_ShouldReturnMinusOne

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

            list.Add(1);
            list.Add(101);
            list.Add(1);
            list.Add(101);

            var index = list.FirstIndexOf(1001);
            Assert.AreEqual(-1, index);
        }
开发者ID:Nezhdetov,项目名称:Software-University,代码行数:12,代码来源:UnitTestsLinkedList.cs

示例6: TestSinglyLinkedListInsert_InsertInTheMiddle

        public void TestSinglyLinkedListInsert_InsertInTheMiddle()
        {
            SinglyLinkedList<string> list = new SinglyLinkedList<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));
        }
开发者ID:Ivan-Dimitrov-bg,项目名称:.Net-framework,代码行数:13,代码来源:SinglyLinkedListTest.cs

示例7: TestSinglyLinkedList

 public void TestSinglyLinkedList()
 {
     SinglyLinkedList<int> singlyLinkedList = new SinglyLinkedList<int>();
     singlyLinkedList.AddAtEnd(5);
     singlyLinkedList.AddAtEnd(6);
     singlyLinkedList.AddAtEnd(7);
     singlyLinkedList.AddAtEnd(8);
     singlyLinkedList.AddAtStart(4);
     singlyLinkedList.AddAtStart(3);
     singlyLinkedList.AddAtStart(2);
     singlyLinkedList.AddAtStart(1);
     singlyLinkedList.Add(9, 10);
     singlyLinkedList.Add(11, 9, true);
     singlyLinkedList.Add(10, 11);
 }
开发者ID:ganesh-narayanan,项目名称:Entrevista,代码行数:15,代码来源:LinkedListTests.cs

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

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

示例10: AddTest

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

示例11: TestSinglyLinkedListForEach

        public void TestSinglyLinkedListForEach()
        {
            SinglyLinkedList<string> list = new SinglyLinkedList<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));
        }
开发者ID:Ivan-Dimitrov-bg,项目名称:.Net-framework,代码行数:19,代码来源:SinglyLinkedListTest.cs

示例12: SortListTest

        public void SortListTest()
        {
            var list = new SinglyLinkedList<int>();
            foreach (int n in a) {
                list.Add(n);
            }

            MergeSort.Sort(list);
            string expected = "[ -59 -45 -12 11 11 44 53 62 80 94 ]";
            string actual = list.ToString();
            Assert.AreEqual(actual, expected);
        }
开发者ID:hirotk,项目名称:Algorithm,代码行数:12,代码来源:MergeSortTest.cs

示例13: Add_EmptyList_ShouldIncrementCount

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

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

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

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

示例15: Add_EmptyList_ShouldAdd

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

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

            int currentItem = 0;
            foreach (var item in list)
            {
                Assert.AreEqual(currentItem, item);
                currentItem++;
            }
        }
开发者ID:Nezhdetov,项目名称:Software-University,代码行数:17,代码来源:UnitTestsLinkedList.cs


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