本文整理汇总了C#中SinglyLinkedList.FirstIndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# SinglyLinkedList.FirstIndexOf方法的具体用法?C# SinglyLinkedList.FirstIndexOf怎么用?C# SinglyLinkedList.FirstIndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SinglyLinkedList
的用法示例。
在下文中一共展示了SinglyLinkedList.FirstIndexOf方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
SinglyLinkedList<int> list = new SinglyLinkedList<int>();
list.AddLast(1);
list.AddLast(2);
list.AddLast(3);
list.AddLast(4);
list.AddLast(5);
list.AddLast(6);
list.AddLast(3);
Console.WriteLine("FirstIndexOf(6): {0}", list.FirstIndexOf(6));
Console.WriteLine("FirstIndexOf(1): {0}", list.FirstIndexOf(1));
Console.WriteLine("FirstIndexOf(16): {0}", list.FirstIndexOf(16));
Console.WriteLine("LastIndexOf(3): {0}", list.LastIndexOf(3));
Console.WriteLine("LastIndexOf(30): {0}", list.LastIndexOf(30));
Console.WriteLine(list.Count);
list.Remove(0);
foreach (var item in list)
{
Console.WriteLine(item);
}
}
示例2: Main
private static void Main()
{
var list = new SinglyLinkedList<int>();
list.ForEach(Console.WriteLine);
Console.WriteLine("--------------------");
list.Add(5);
list.Add(3);
list.Add(2);
list.Add(10, 1);
list.Add(5);
list.Add(99);
Console.WriteLine("Count = {0}", list.Count);
list.ForEach(Console.WriteLine);
Console.WriteLine("--------------------");
list.Remove(1);
Console.WriteLine("Count = {0}", list.Count);
list.ForEach(Console.WriteLine);
Console.WriteLine("--------------------");
Console.WriteLine(list.FirstIndexOf(5));
Console.WriteLine("--------------------");
Console.WriteLine(list.LastIndexOf(5));
}
示例3: FirstIndexOf_NonExistingItem_ShouldReturnMinusOne
public void FirstIndexOf_NonExistingItem_ShouldReturnMinusOne()
{
var list = new SinglyLinkedList<int>();
list.Add(1);
list.Add(101);
list.Add(1);
list.Add(101);
var index = list.FirstIndexOf(1001);
Assert.AreEqual(-1, index);
}
示例4: FirstIndexOf_ExistingItem_ShouldReturnCorrectIndex
public void FirstIndexOf_ExistingItem_ShouldReturnCorrectIndex()
{
var list = new SinglyLinkedList<int>();
list.Add(1);
list.Add(101);
list.Add(1);
list.Add(101);
var index = list.FirstIndexOf(1);
Assert.AreEqual(0, index);
}
示例5: Main
static void Main()
{
var myList = new SinglyLinkedList<int>();
myList.Add(1);
myList.Add(2);
myList.Add(3);
myList.Add(2);
myList.Add(1);
Console.WriteLine(string.Join(" ", myList));
Console.WriteLine(myList.FirstIndexOf(2));
myList.Remove(4);
Console.WriteLine(string.Join(" ", myList));
Console.WriteLine(myList.Count);
}