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


C# DoublyLinkedList类代码示例

本文整理汇总了C#中DoublyLinkedList的典型用法代码示例。如果您正苦于以下问题:C# DoublyLinkedList类的具体用法?C# DoublyLinkedList怎么用?C# DoublyLinkedList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: InsertionSort

        private static void InsertionSort(DoublyLinkedList<double> bucket)
        {
            if (bucket.Head == null)
            {
                return;
            }

            var currentNode = bucket.Head.Next;
            while (currentNode != null)
            {
                var node = currentNode.Previous;
                while (node != null && node.Value > currentNode.Value)
                {
                    node = node.Previous;
                }

                bucket.Delete(currentNode);
                if (node != null)
                {
                    bucket.InsertAfter(node, currentNode.Value);
                }
                else
                {
                    bucket.Insert(currentNode.Value);
                }

                currentNode = currentNode.Next;
            }
        }
开发者ID:moozzyk,项目名称:AlgorithmsInCSharp,代码行数:29,代码来源:BucketSort.cs

示例2: should_make_the_node_head_and_tail_of_the_list

 public void should_make_the_node_head_and_tail_of_the_list()
 {
     var list = new DoublyLinkedList<int>();
     list.Add(3);
     Assert.That(list.Head.Data.Equals(3), Is.True);
     Assert.That(list.Tail.Data.Equals(3), Is.True);
 }
开发者ID:bonniepan02,项目名称:Practice,代码行数:7,代码来源:DoublyLinkedListTest.cs

示例3: Sort

        public static void Sort(double[] array)
        {
            var buckets = new DoublyLinkedList<double>[10];
            for (var i = 0; i < buckets.Length; i++)
            {
                buckets[i] = new DoublyLinkedList<double>();
            }

            foreach (var v in array)
            {
                if (v < 0 || v >= 1)
                {
                    throw new InvalidOperationException($"{v} is not in [0..1) range.");
                }
                buckets[(int)(v * 10)].Insert(v);
            }

            foreach (var bucket in buckets)
            {
                InsertionSort(bucket);
            }

            var index = 0;
            foreach (var bucket in buckets)
            {
                for (var node = bucket.Head; node != null; node = node.Next)
                {
                    array[index++] = node.Value;
                }
            }
        }
开发者ID:moozzyk,项目名称:AlgorithmsInCSharp,代码行数:31,代码来源:BucketSort.cs

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

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

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

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

示例8: AddAfterTailPUT

 public void AddAfterTailPUT([PexAssumeUnderTest]IList<int> values, int toAddValue)
 {
     PexAssume.IsTrue(values.Count > 1);
     PexAssume.IsFalse(values.Contains(toAddValue));
     DoublyLinkedList<int> dll = new DoublyLinkedList<int> (values);
     dll.AddAfter(dll.Tail, toAddValue);
     PexAssert.AreEqual(toAddValue, dll.Tail.Value);
     PexAssert.AreEqual(values[values.Count - 1], dll.Tail.Previous.Value);
 }
开发者ID:taoxiease,项目名称:asegrp,代码行数:9,代码来源:DoublyLinkedListTest.cs

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

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

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

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

示例13: CopyTo

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

            list.CopyTo(array, 1);

            CollectionAssert.AreEqual(new[] {0, 1, 2, 3}, array);
        }
开发者ID:ZenLulz,项目名称:DoublyLinkedList.NET,代码行数:9,代码来源:DoublyLinkedListTests.cs

示例14: AddAfterTailTest

        public void AddAfterTailTest()
        {
            DoublyLinkedList<int> dll = new DoublyLinkedList<int> {10};

            dll.AddAfter(dll.Head, 20);

            Assert.AreEqual(20, dll.Tail.Value);
            Assert.AreEqual(10, dll.Tail.Previous.Value);
        }
开发者ID:robertrancz,项目名称:dsa,代码行数:9,代码来源:DoublyLinkedListTest.cs

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


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