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


C# SinglyLinkedList.RemoveFirst方法代码示例

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


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

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

示例2: TestRemoveFirst

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

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

            list.RemoveFirst();

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

示例3: RemoveFirstOneItemInListTest

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

            sll.RemoveFirst();

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

示例4: RemoveFirstEmptyListTest

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

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

示例5: Removing_Should_decrement_length

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

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

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

示例6: RemoveFirst_Should_change_tail_when_list_is_empty

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

            list = list.RemoveFirst();
            Assert.That(list.Head, Is.Null);
            Assert.That(list.Tail, Is.Null);
        }
开发者ID:evilz,项目名称:algorithm-datastructure,代码行数:8,代码来源:SimpleLinkedListTests.cs

示例7: RemoveFirst_Should_change_head

        public void RemoveFirst_Should_change_head()
        {
            ISinglyLinkedList<int> list = new SinglyLinkedList<int>(new[] { 1,2,3 });

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


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