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


C# DoublyLinkedList.AddLast方法代码示例

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


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

示例1: Main

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

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

            list.AddLast(5);
            list.AddFirst(3);
            list.AddFirst(2);
            list.AddLast(10);
            Console.WriteLine("Count = {0}", list.Count);

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

            list.RemoveFirst();
            list.RemoveLast();
            list.RemoveFirst();

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

            list.RemoveLast();

            list.ForEach(Console.WriteLine);
            Console.WriteLine("--------------------");
        }
开发者ID:Nezhdetov,项目名称:Software-University,代码行数:28,代码来源:Example.cs

示例2: AddLastTest

        public void AddLastTest()
        {
            var list = new DoublyLinkedList<int>();
            list.AddLast(2);
            list.AddLast(4);
            list.AddLast(6);

            Assert.AreEqual(list.Head.Value, 2);
            Assert.AreEqual(list.Tail.Value, 6);
        }
开发者ID:er0dr1guez,项目名称:AlgorithmsAndDataStructures,代码行数:10,代码来源:DoublyLinkedListTest.cs

示例3: ClearTest

        public void ClearTest()
        {
            var list = new DoublyLinkedList<int>();
            list.AddLast(2);
            list.AddLast(4);
            list.AddLast(6);

            list.Clear();

            Assert.AreEqual(list.Head, null);
        }
开发者ID:er0dr1guez,项目名称:AlgorithmsAndDataStructures,代码行数:11,代码来源:DoublyLinkedListTest.cs

示例4: Add

        public void Add()
        {
            var list = new DoublyLinkedList<int>(2);

            list.AddFirst(1);
            list.AddLast(3);
            list.AddFirst(0);
            list.AddLast(4);

            for (var i = 0; i < 5; i++)
            {
                Assert.AreEqual(i, list[i].Value);
            }
        }
开发者ID:ZenLulz,项目名称:DoublyLinkedList.NET,代码行数:14,代码来源:DoublyLinkedListTests.cs

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

示例6: Main

 static void Main(string[] args)
 {
     try
     {
         DoublyLinkedList<Person> list = new DoublyLinkedList<Person>();
         list.AddFirst(new Person("Nikita Vasilyev", 24));
         list.AddFirst(new Person("Bill Gates", 59));
         list.AddFirst(new Person("Muhhamed Ali", 76));
         list.AddLast(new Person("Lennox Lewis", 46));
         list.InsertAt(new Person("Steve Jobs", 54), 2);
         list.Show();
         list.RemoveAt(4);
         Console.WriteLine(list[2]);
         Person p = new Person("Nikita Vasilyev", 24);
         Console.WriteLine(list.Find(p));
         list.FindLast(p).FullName = "Nikita V. Vasilyev";
         list.ShowReverse();
         list.Show();
     }
     catch (IndexOutOfRangeException ex)
     {
         Console.WriteLine("Message:\t" + ex.Message);
         Console.WriteLine("Method:\t\t" + ex.TargetSite);
     }
     catch (ArgumentNullException ex)
     {
         Console.WriteLine("Message:\t" + ex.Message);
         Console.WriteLine("Method:\t\t" + ex.TargetSite);
     }
     catch (InvalidOperationException ex)
     {
         Console.WriteLine("Message:\t" + ex.Message);
         Console.WriteLine("Method:\t\t" + ex.TargetSite);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Message:\t" + ex.Message);
         Console.WriteLine("Method:\t\t" + ex.TargetSite);
     }
 }
开发者ID:NikitaVas,项目名称:CSharp,代码行数:40,代码来源:Program.cs

示例7: Traverse

        public void Traverse()
        {
            var list = new DoublyLinkedList<int>(new[] { 1, 2, 3 });

            // Perform various operations
            list.AddFirst(0);
            list.RemoveFirst();
            list.AddLast(0);
            list.RemoveLast();
            list.Insert(1, 0);
            list.RemoveAt(1);

            var current = list.First;

            while (current.Next != null)
            {
                current = current.Next;
            }
            Assert.AreEqual(list.Last, current);

            while (current.Previous != null)
            {
                current = current.Previous;
            }
            Assert.AreEqual(list.First, current);
        }
开发者ID:ZenLulz,项目名称:DoublyLinkedList.NET,代码行数:26,代码来源:DoublyLinkedListTests.cs


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