本文整理汇总了C#中DoublyLinkedList.RemoveLast方法的典型用法代码示例。如果您正苦于以下问题:C# DoublyLinkedList.RemoveLast方法的具体用法?C# DoublyLinkedList.RemoveLast怎么用?C# DoublyLinkedList.RemoveLast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoublyLinkedList
的用法示例。
在下文中一共展示了DoublyLinkedList.RemoveLast方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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("--------------------");
}
示例2: Remove
public void Remove()
{
var list = new DoublyLinkedList<int>(new [] {0, 1, 2, 3, 4, 5});
list.RemoveFirst();
list.RemoveLast();
list.RemoveFirst();
list.RemoveLast();
for (var i = 2; i < 4; i++)
{
Assert.AreEqual(i, list[i - 2].Value);
}
}
示例3: RemoveLastPUT
public void RemoveLastPUT([PexAssumeUnderTest]IList<int> values)
{
DoublyLinkedList<int> dll = new DoublyLinkedList<int>(values);
bool returnVal = dll.RemoveLast();
if (values.Count > 0)
{
PexAssert.IsTrue(returnVal);
if (values.Count > 1)
{
PexAssert.AreEqual(values[values.Count-2], dll.Tail.Value);
PexAssert.IsNull(dll.Tail.Next);
}
else
{
PexAssert.IsNull(dll.Head);
PexAssert.IsNull(dll.Tail);
}
}
else
{
PexAssert.IsFalse(returnVal);
}
}
示例4: 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);
}
示例5: 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);
}
示例6: RemoveLastTwoNodesTest
public void RemoveLastTwoNodesTest()
{
DoublyLinkedList<int> dll = new DoublyLinkedList<int> {10, 20};
Assert.IsTrue(dll.RemoveLast());
Assert.AreEqual(10, dll.Head.Value);
Assert.AreEqual(10, dll.Tail.Value);
Assert.IsNull(dll.Tail.Next);
Assert.IsNull(dll.Head.Next);
}
示例7: RemoveLastTestMultipleNodesTest
public void RemoveLastTestMultipleNodesTest()
{
DoublyLinkedList<int> dll = new DoublyLinkedList<int> {10, 20, 30};
dll.RemoveLast();
Assert.AreEqual(20, dll.Tail.Value);
Assert.IsNull(dll.Tail.Next);
}
示例8: RemoveLastTest
public void RemoveLastTest()
{
DoublyLinkedList<int> dll = new DoublyLinkedList<int> {10};
dll.RemoveLast();
Assert.IsTrue(dll.IsEmpty());
Assert.IsFalse(dll.RemoveLast());
Assert.IsNull(dll.Tail);
}
示例9: RemoveLastEmptyListTest
public void RemoveLastEmptyListTest()
{
DoublyLinkedList<int> dll = new DoublyLinkedList<int>();
dll.RemoveLast();
}
示例10: 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);
}