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


C# DoublyLinkedList.AddBefore方法代码示例

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


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

示例1: CountPUT

        public void CountPUT([PexAssumeUnderTest]IList<int> values, int randomPick1)
        {
            PexAssume.IsFalse(values.Contains(randomPick1));
            PexAssume.IsTrue(values.Count > 1);
            DoublyLinkedList<int> dll = new DoublyLinkedList<int> (values);

            dll.RemoveFirst();
            dll.RemoveLast();
            PexAssert.AreEqual(values.Count-2, dll.Count);

            dll.Add(randomPick1);
            dll.AddAfter(dll.Head, values[0]);
            dll.AddBefore(dll.Head.Next, values[values.Count-1]);
            PexAssert.AreEqual(values.Count+1, dll.Count);
        }
开发者ID:taoxiease,项目名称:asegrp,代码行数:15,代码来源:DoublyLinkedListTest.cs

示例2: AddBeforePUT

 public void AddBeforePUT([PexAssumeUnderTest]IList<int> values, int toAddValue)
 {
     PexAssume.IsFalse(values.Contains(toAddValue));
     DoublyLinkedList<int> dll = new DoublyLinkedList<int>(values);
     if (values.Count == 0)
     {
         dll.AddBefore(dll.Head, toAddValue);
         PexAssert.IsFalse(true, "InvalidOperationException was expected");
     }
     dll.AddBefore(dll.Head.Next, toAddValue);
     if (values.Count == 1)
     {
         PexAssert.IsFalse(true, "ArgumentNullException was expected");
     }
     PexAssert.AreEqual(toAddValue, dll.Head.Next.Value);
     PexAssert.AreEqual(values[0], dll.Head.Next.Previous.Value);
     PexAssert.AreEqual(values[1], dll.Head.Next.Next.Value);
     if(values.Count == 2)
         PexAssert.AreEqual(toAddValue, dll.Tail.Previous.Value);
 }
开发者ID:taoxiease,项目名称:asegrp,代码行数:20,代码来源:DoublyLinkedListTest.cs

示例3: AddBeforeHeadTest

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

            dll.AddBefore(dll.Head, 5);

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

示例4: AddBeforeEmptyListTest

        public void AddBeforeEmptyListTest()
        {
            DoublyLinkedList<int> dll = new DoublyLinkedList<int>();

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

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

示例6: AddBeforeTest

        public void AddBeforeTest()
        {
            DoublyLinkedList<int> dll = new DoublyLinkedList<int> {10, 30};

            dll.AddBefore(dll.Head.Next, 20);

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

示例7: AddBeforeNullNode

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

            dll.AddBefore(dll.Head.Next, 20);
        }
开发者ID:robertrancz,项目名称:dsa,代码行数:6,代码来源:DoublyLinkedListTest.cs


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