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


C# DoublyLinkedList.Add方法代码示例

本文整理汇总了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);
 }
开发者ID:bonniepan02,项目名称:Practice,代码行数:8,代码来源:DoublyLinkedListTest.cs

示例2: BeginTestMethod

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

示例3: Clear

 public void Clear()
 {
     DoublyLinkedList<int> list = new DoublyLinkedList<int>();
     list.Add(3);
     list.Add(5);
     list.Add(7);
     list.Clear();
     list.ShouldBeEmpty();
 }
开发者ID:paulcicio,项目名称:Training,代码行数:9,代码来源:DoublyLinkedListTests.cs

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

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

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

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

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

示例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);
        }
开发者ID:Ivan-Dimitrov-bg,项目名称:.Net-framework,代码行数:9,代码来源:DoublyLinkedListTest.cs

示例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));
        }
开发者ID:Ivan-Dimitrov-bg,项目名称:.Net-framework,代码行数:12,代码来源:DoublyLinkedListTest.cs

示例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);
 }
开发者ID:paulcicio,项目名称:Training,代码行数:12,代码来源:DoublyLinkedListTests.cs

示例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));
        }
开发者ID:Ivan-Dimitrov-bg,项目名称:.Net-framework,代码行数:13,代码来源:DoublyLinkedListTest.cs

示例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));
        }
开发者ID:Ivan-Dimitrov-bg,项目名称:.Net-framework,代码行数:19,代码来源:DoublyLinkedListTest.cs

示例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);
            }
开发者ID:bonniepan02,项目名称:Practice,代码行数:19,代码来源:DoublyLinkedListTest.cs

示例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);
        }
开发者ID:robertrancz,项目名称:dsa,代码行数:12,代码来源:DoublyLinkedListTest.cs


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