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


C# SinglyLinkedList.AddLast方法代码示例

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


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

示例1: TestAddAfterNoNext

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

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

            list.AddAfter(node, 2);

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

示例2: TestAddBefore

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

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

            list.AddBefore(node, 1);

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

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

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

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

示例6: AddLast_Should_change_tail_and_set_next_of_previous_tail

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

            var previous = list.Tail;
            list = list.AddLast(2);
            Assert.That(list.Tail.Data, Is.EqualTo(2));
            Assert.That(previous.Next, Is.EqualTo(list.Tail));
        }
开发者ID:evilz,项目名称:algorithm-datastructure,代码行数:9,代码来源:SimpleLinkedListTests.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: 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

示例9: TestRemoveNode

        public void TestRemoveNode()
        {
            var list = new SinglyLinkedList<string>();
            list.AddLast("Expected");
            list.AddLast("Expected");
            var notExpected = list.AddLast("Not expected");
            list.AddLast("Expected");
            list.Remove(notExpected);

            bool found = false;
            var current = list.First;
            while (current != null && !found)
            {
                found = current == notExpected;
                current = current.Next;
            }

            Assert.IsFalse(found);
        }
开发者ID:Bpoe,项目名称:Data-Structures-and-Algorithms,代码行数:19,代码来源:SinglyLinkedListTests.cs

示例10: TestRemoveLast

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

            var list = new SinglyLinkedList<int>(expected);
            list.AddLast(-1);
            Assert.AreEqual(-1, list.Last.Value);

            list.RemoveLast();

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

示例11: TestEnumerator

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

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

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

示例12: TestAddLast

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

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

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

示例13: RemoveFirstTest

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

            sll.AddFirst(40);
            sll.AddFirst(30);
            sll.AddFirst(20);
            sll.AddFirst(10);
            sll.AddLast(50);
            sll.RemoveFirst();
            sll.RemoveFirst();

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


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