本文整理匯總了C#中SinglyLinkedLists.SinglyLinkedList.Sort方法的典型用法代碼示例。如果您正苦於以下問題:C# SinglyLinkedList.Sort方法的具體用法?C# SinglyLinkedList.Sort怎麽用?C# SinglyLinkedList.Sort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SinglyLinkedLists.SinglyLinkedList
的用法示例。
在下文中一共展示了SinglyLinkedList.Sort方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: SortingWithInt
public void SortingWithInt()
{
SinglyLinkedList<int> list = new SinglyLinkedList<int>(new int[] { 4, 1, 3, 2 });
list.Sort();
int[] expected = { 1, 2, 3, 4 };
CollectionAssert.AreEqual(expected, list.ToArray());
}
示例2: SortUnsortedList
public void SortUnsortedList()
{
SinglyLinkedList list = new SinglyLinkedList("foo", "bar");
list.Sort();
var expected = new string[] { "bar", "foo" };
CollectionAssert.AreEqual(expected, list.ToArray());
}
示例3: SortEmptyList
public void SortEmptyList()
{
SinglyLinkedList list = new SinglyLinkedList();
list.Sort();
var expected = new string[] { };
CollectionAssert.AreEqual(expected, list.ToArray());
}
示例4: SortUnsortedList
public void SortUnsortedList()
{
SinglyLinkedList list = new SinglyLinkedList("foo", "bar");
list.Sort();
var expected = new string[] { "bar", "foo" };
// This passes, but removing the ToString() fails. WHY???
Assert.AreEqual(expected.ToString(), list.ToArray().ToString());
// Assert.AreEqual(2, list.Count()) works
// Assert.AreEqual("bar", list.ToArray()[0]) works
// Assert.AreEqual("foo", list.ToArray()[1]) works
}
示例5: SortThenGetLast
public void SortThenGetLast()
{
SinglyLinkedList<string> list = new SinglyLinkedList<string>("foo", "bar", "grille", "zoo", "cat");
list.Sort();
Assert.AreEqual("zoo", list.Last());
}
示例6: SortSortedList
public void SortSortedList()
{
SinglyLinkedList<string> list = new SinglyLinkedList<string>("bar", "cat", "foo", "grille");
list.Sort();
var expected = new string[] { "bar", "cat", "foo", "grille" };
CollectionAssert.AreEqual(expected, list.ToArray());
}
示例7: SortSingleItemList
public void SortSingleItemList()
{
SinglyLinkedList<string> list = new SinglyLinkedList<string>("foo");
list.Sort();
var expected = new string[] { "foo" };
CollectionAssert.AreEqual(expected, list.ToArray());
}
示例8: SortLongerList
public void SortLongerList()
{
SinglyLinkedList list = new SinglyLinkedList("foo", "bar", "grille", "zoo", "cat");
list.Sort();
var expected = new string[] { "bar", "cat", "foo", "grille", "zoo" };
//throw new ArgumentException(list.ToString());
CollectionAssert.AreEqual(expected, list.ToArray());
}