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


C# SinglyLinkedList.AddAfter方法代码示例

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


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

示例1: AddAfter_Should_change_tail_and_set_next_item_of_previous_item

        public void AddAfter_Should_change_tail_and_set_next_item_of_previous_item()
        {
            ISinglyLinkedList<int> list = new SinglyLinkedList<int>(new [] {1});

            var previous = list.Head;
            list = list.AddAfter(2,previous);
            Assert.That(list.Tail.Data,Is.EqualTo(2));
            Assert.That(previous.Next, Is.EqualTo(list.Tail));
            list = list.AddAfter(3, previous);
            Assert.That(list.Tail.Data, Is.EqualTo(2));
            Assert.That(previous.Next.Data, Is.EqualTo(3));
        }
开发者ID:evilz,项目名称:algorithm-datastructure,代码行数:12,代码来源:SimpleLinkedListTests.cs

示例2: AddAfterTailTest

        public void AddAfterTailTest()
        {
            SinglyLinkedList<int> sll = new SinglyLinkedList<int> {10, 20};

            sll.AddAfter(sll.Tail, 30);

            Assert.AreEqual(30, sll.Tail.Value);
            Assert.AreEqual(30, sll.Head.Next.Next.Value);
            Assert.AreEqual(3, sll.Count);
        }
开发者ID:robertrancz,项目名称:dsa,代码行数:10,代码来源:SinglyLinkedListTest.cs

示例3: AddAfterMiddleNodeTest

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

            sll.AddAfter(sll.Head.Next, 25);

            Assert.AreEqual(25, sll.Head.Next.Next.Value);
            Assert.AreEqual(30, sll.Head.Next.Next.Next.Value);
            Assert.AreEqual(4, sll.Count);
        }
开发者ID:robertrancz,项目名称:dsa,代码行数:10,代码来源:SinglyLinkedListTest.cs

示例4: AddAfterOnlyOneNodeInListTest

        public void AddAfterOnlyOneNodeInListTest()
        {
            SinglyLinkedList<int> sll = new SinglyLinkedList<int> {10};

            sll.AddAfter(sll.Head, 20);

            Assert.AreEqual(20, sll.Tail.Value);
            Assert.AreEqual(10, sll.Head.Value);
            Assert.AreEqual(20, sll.Head.Next.Value);
            Assert.AreEqual(2, sll.Count);
        }
开发者ID:robertrancz,项目名称:dsa,代码行数:11,代码来源:SinglyLinkedListTest.cs

示例5: TestAddAfterNoPrevious

        public void TestAddAfterNoPrevious()
        {
            var expected = new int[3] { 0, 1, 2 };

            var list = new SinglyLinkedList<int>();
            var node = list.AddLast(0);
            list.AddLast(2);

            list.AddAfter(node, 1);

            Verify(expected, list);
        }
开发者ID:Bpoe,项目名称:Data-Structures-and-Algorithms,代码行数:12,代码来源:SinglyLinkedListTests.cs

示例6: TestAddAfterLast

        public void TestAddAfterLast()
        {
            var expected = new int[3] { 0, 1, 2 };

            var list = new SinglyLinkedList<int>();
            list.AddLast(0);
            list.AddLast(1);

            var node = list.AddAfter(list.Last, 2);

            Verify(expected, list);
            Assert.AreSame(list.Last, node);
        }
开发者ID:Bpoe,项目名称:Data-Structures-and-Algorithms,代码行数:13,代码来源:SinglyLinkedListTests.cs

示例7: Adding_Should_increment_length

        public void Adding_Should_increment_length()
        {
            ISinglyLinkedList<int> list = new SinglyLinkedList<int>(new[] { 1 });
            Assert.That(list.Length, Is.EqualTo(1));

            list = list.AddAfter(2,list.Tail);
            Assert.That(list.Length, Is.EqualTo(2));

            list = list.AddFirst(3);
            Assert.That(list.Length, Is.EqualTo(3));

            list = list.AddLast(4);
            Assert.That(list.Length, Is.EqualTo(4));
        }
开发者ID:evilz,项目名称:algorithm-datastructure,代码行数:14,代码来源:SimpleLinkedListTests.cs

示例8: AddAfterEmptyNullNodeTest

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

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

示例9: AddAfterEmptyNullNodeTest

 public void AddAfterEmptyNullNodeTest(int elementToAdd)
 {
     SinglyLinkedList<int> sll = new SinglyLinkedList<int>();
     sll.AddAfter(sll.Head, elementToAdd);
 }
开发者ID:taoxiease,项目名称:asegrp,代码行数:5,代码来源:SinglyLinkedListTest.cs


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