本文整理汇总了C#中SortableCollection.PrintAllItemsOnConsole方法的典型用法代码示例。如果您正苦于以下问题:C# SortableCollection.PrintAllItemsOnConsole方法的具体用法?C# SortableCollection.PrintAllItemsOnConsole怎么用?C# SortableCollection.PrintAllItemsOnConsole使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortableCollection
的用法示例。
在下文中一共展示了SortableCollection.PrintAllItemsOnConsole方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
internal static void Main(string[] args)
{
var collection = new SortableCollection<int>(new[] { 22, 11, 101, 33, 0, 101 });
Console.WriteLine("All items before sorting:");
collection.PrintAllItemsOnConsole();
Console.WriteLine("SelectionSorter result:");
collection.Sort(new SelectionSorter<int>());
collection.PrintAllItemsOnConsole();
collection = new SortableCollection<int>(new[] { 22, 11, 101, 33, 0, 101 });
Console.WriteLine("Quicksorter result:");
collection.Sort(new QuickSorter<int>());
collection.PrintAllItemsOnConsole();
collection = new SortableCollection<int>(new[] { 22, 11, 101, 33, 0, 101 });
Console.WriteLine("MergeSorter result:");
collection.Sort(new MergeSorter<int>());
collection.PrintAllItemsOnConsole();
Console.WriteLine("Linear search 101:");
Console.WriteLine(collection.LinearSearch(101) + Environment.NewLine);
Console.WriteLine("Binary search 101:");
Console.WriteLine(collection.BinarySearch(101) + Environment.NewLine);
Console.WriteLine("Shuffle:");
collection.Shuffle();
collection.PrintAllItemsOnConsole();
Console.WriteLine("Shuffle again:");
collection.Shuffle();
collection.PrintAllItemsOnConsole();
}
示例2: Main
internal static void Main(string[] args)
{
var collection = new SortableCollection<int>(new[] { 22, -2, 300, 11, 55, 33, 10, -15, 88, 101, 33, 0, 101, 44, 33 });
Console.WriteLine("All items before sorting:");
collection.PrintAllItemsOnConsole();
Console.WriteLine();
Console.WriteLine("SelectionSorter result:");
collection.Sort(new SelectionSorter<int>());
collection.PrintAllItemsOnConsole();
Console.WriteLine();
collection = new SortableCollection<int>(new[] { 22, -2, 300, 11, 55, 33, 10, -15, 88, 101, 33, 0, 101, 44, 33 });
Console.WriteLine("Quicksorter result:");
var quickSorter = new Quicksorter<int>();
collection.Sort(quickSorter);
quickSorter.PrintResults();
//collection.PrintAllItemsOnConsole();
Console.WriteLine();
collection = new SortableCollection<int>(new[] { 22, -2, 300, 11, 55, 33, 10, -15, 88, 101, 33, 0, 101, 44, 33 });
Console.WriteLine("MergeSorter result:");
var mergeSort = new MergeSorter<int>();
collection.Sort(mergeSort);
mergeSort.ShowResults();
//collection.PrintAllItemsOnConsole();
Console.WriteLine();
Console.WriteLine("Linear search 101:");
Console.WriteLine(collection.LinearSearch(101));
Console.WriteLine();
Console.WriteLine("Binary search 101:");
Console.WriteLine(collection.BinarySearch(101));
Console.WriteLine();
collection = new SortableCollection<int>(new int[20]);
for (int i = 1; i <= 20; i++)
{
collection.Items[i - 1] = i;
}
Console.WriteLine("All items before sorting:");
collection.PrintAllItemsOnConsole();
Console.WriteLine("Shuffle:");
collection.Shuffle();
collection.PrintAllItemsOnConsole();
Console.WriteLine();
Console.WriteLine("Shuffle again:");
collection.Shuffle();
collection.PrintAllItemsOnConsole();
}
示例3: Main
internal static void Main(string[] args)
{
var collection = new SortableCollection<int>(new[] { 22, 11, 101, 33, 0, 101 });
Console.WriteLine("All items before sorting:");
collection.PrintAllItemsOnConsole();
Console.WriteLine();
///
/// Uncomment the sort you want to see and leave
/// others commented
///
//Console.WriteLine("SelectionSorter result:");
//collection.Sort(new SelectionSorter<int>());
//collection.PrintAllItemsOnConsole();
//Console.WriteLine();
Console.WriteLine("Quicksorter result:");
collection.Sort(new Quicksorter<int>());
collection.PrintAllItemsOnConsole();
Console.WriteLine();
//Console.WriteLine("MergeSorter result:");
//collection.Sort(new MergeSorter<int>());
//collection.PrintAllItemsOnConsole();
//Console.WriteLine();
Console.WriteLine("Linear search 101:");
Console.WriteLine(collection.LinearSearch(101));
Console.WriteLine();
Console.WriteLine("Binary search 101:");
Console.WriteLine(collection.BinarySearch(101));
Console.WriteLine();
Console.WriteLine("Shuffle:");
collection.Shuffle();
collection.PrintAllItemsOnConsole();
Console.WriteLine();
Console.WriteLine("Shuffle again:");
collection.Shuffle();
collection.PrintAllItemsOnConsole();
}
示例4: Main
internal static void Main()
{
var collection = new SortableCollection<int>(new[] { 22, 11, 101, 33, 0, 101 });
Console.WriteLine("All items before sorting:");
collection.PrintAllItemsOnConsole();
Console.WriteLine();
Console.WriteLine("SelectionSorter result:");
collection.Sort(new SelectionSorter<int>());
collection.PrintAllItemsOnConsole();
Console.WriteLine();
collection = new SortableCollection<int>(new[] { 22, 11, 101, 33, 0, 101 });
Console.WriteLine("QuickSorter result:");
collection.Sort(new QuickSorter<int>());
collection.PrintAllItemsOnConsole();
Console.WriteLine();
collection = new SortableCollection<int>(new[] { 22, 11, 101, 33, 0, 101 });
Console.WriteLine("MergeSorter result:");
collection.Sort(new MergeSorter<int>());
collection.PrintAllItemsOnConsole();
Console.WriteLine();
Console.WriteLine("Linear search 101:");
Console.WriteLine(collection.LinearSearch(101));
Console.WriteLine();
Console.WriteLine("Binary search 101:");
Console.WriteLine(collection.BinarySearch(101));
Console.WriteLine();
Console.WriteLine("Shuffle:");
collection.Shuffle();
collection.PrintAllItemsOnConsole();
Console.WriteLine();
Console.WriteLine("Shuffle again:");
collection.Shuffle();
collection.PrintAllItemsOnConsole();
Console.WriteLine();
Console.WriteLine("Test sort performance:");
PerformanceTester.Test(new SelectionSorter<int>(), new QuickSorter<int>(), new MergeSorter<int>());
}
示例5: Main
public static void Main()
{
var collection = new SortableCollection<int>(new[] { 13, 29, 22, 11, 7, 33, 0, 101 });
Console.WriteLine("All items before sorting:");
collection.PrintAllItemsOnConsole();
Console.WriteLine();
//Console.WriteLine("SelectionSorter result:");
//collection.Sort(new SelectionSorter<int>());
//collection.PrintAllItemsOnConsole();
//Console.WriteLine();
//Console.WriteLine("Quicksorter result:");
//collection.Sort(new Quicksorter<int>());
//collection.PrintAllItemsOnConsole();
//Console.WriteLine();
//Console.WriteLine("MergeSorter result:");
//collection.Sort(new MergeSorter<int>());
//collection.PrintAllItemsOnConsole();
//Console.WriteLine();
//Console.WriteLine("Linear search 101:");
//Console.WriteLine(collection.LinearSearch(101));
//Console.WriteLine();
//Console.WriteLine("Binary search 101:");
//Console.WriteLine(collection.BinarySearch(101));
//Console.WriteLine();
Console.WriteLine("Shuffle:");
collection.Shuffle();
collection.PrintAllItemsOnConsole();
Console.WriteLine();
Console.WriteLine("Shuffle again:");
collection.Shuffle();
collection.PrintAllItemsOnConsole();
Console.WriteLine();
Console.WriteLine("Shuffle again:");
collection.Shuffle();
collection.PrintAllItemsOnConsole();
}
示例6: Main
internal static void Main(string[] args)
{
var collection = new SortableCollection<int>(new[] { 77, 332, 651, 98, 1, 5454, 34, 1, 656, 1, 22, 11, 101, 33, 0, 101 });
Console.WriteLine("All items before sorting:");
collection.PrintAllItemsOnConsole();
Console.WriteLine();
Console.WriteLine("SelectionSorter result:");
collection.Sort(new SelectionSorter<int>());
collection.PrintAllItemsOnConsole();
Console.WriteLine();
collection = new SortableCollection<int>(new[] { 77, 332, 651, 98, 1, 5454, 34, 1, 656, 1, 22, 11, 101, 33, 0, 101 });
Console.WriteLine("Quicksorter result:");
collection.Sort(new Quicksorter<int>());
collection.PrintAllItemsOnConsole();
Console.WriteLine();
collection = new SortableCollection<int>(new[] { 77, 332, 651, 98, 1, 5454, 34, 1, 656, 1, 22, 11, 101, 33, 0, 101 });
Console.WriteLine("MergeSorter result:");
collection.Sort(new MergeSorter<int>());
collection.PrintAllItemsOnConsole();
Console.WriteLine();
Console.WriteLine("Linear search 11:");
Console.WriteLine(collection.LinearSearch(11));
Console.WriteLine();
Console.WriteLine("Binary search 11:");
Console.WriteLine(collection.BinarySearch(11));
Console.WriteLine();
Console.WriteLine("Shuffle:");
collection.Shuffle();
collection.PrintAllItemsOnConsole();
Console.WriteLine();
Console.WriteLine("Shuffle again:");
collection.Shuffle();
collection.PrintAllItemsOnConsole();
}
示例7: Main
static void Main()
{
SortableCollection<int> collection = new SortableCollection<int>(new[] { 34, 12, 11, 312, 86, 14, 5, 88 });
Console.WriteLine("Collection before sorting:");
collection.PrintAllItemsOnConsole();
Console.WriteLine();
Console.WriteLine("SelectionSorter output:");
collection.Sort(new SelectionSorter<int>());
collection.PrintAllItemsOnConsole();
Console.WriteLine();
Console.WriteLine("Quicksorter output:");
collection.Sort(new Quicksorter<int>());
collection.PrintAllItemsOnConsole();
Console.WriteLine();
Console.WriteLine("MergeSorter output:");
collection.Sort(new MergeSorter<int>());
collection.PrintAllItemsOnConsole();
Console.WriteLine();
Console.WriteLine("Linear search at 86:");
Console.WriteLine(collection.LinearSearch(86));
Console.WriteLine();
Console.WriteLine("Binary search at 14:");
Console.WriteLine(collection.BinarySearch(14));
Console.WriteLine();
Console.WriteLine("Shuffle:");
collection.Shuffle();
collection.PrintAllItemsOnConsole();
Console.WriteLine();
}
示例8: Main
internal static void Main(string[] args)
{
try
{
var collection = new SortableCollection<int>(new[] { 22, 13, 23, 45, -55, 90, 100, 101, -12, 55, 44 });
var collection1 = new SortableCollection<string>(new[] { "aaaa", "cccc", "dddd", "cccc", "caaa", "aacc", "bbdd", "ccff", "eerr", "rrtt", "assdd" });
Console.WriteLine("All items before sorting:");
collection.PrintAllItemsOnConsole();
Console.WriteLine();
Console.WriteLine("SelectionSorter result:");
collection.Sort(new SelectionSorter<int>());
collection1.Sort(new SelectionSorter<string>());
collection.PrintAllItemsOnConsole();
collection1.PrintAllItemsOnConsole();
Console.WriteLine();
Console.WriteLine("Quicksorter result:");
collection.Sort(new Quicksorter<int>());
collection.PrintAllItemsOnConsole();
collection1.Sort(new Quicksorter<string>());
collection1.PrintAllItemsOnConsole();
Console.WriteLine();
Console.WriteLine("MergeSorter result:");
collection.Sort(new MergeSorter<int>());
collection.PrintAllItemsOnConsole();
collection1.Sort(new Quicksorter<string>());
collection1.PrintAllItemsOnConsole();
Console.WriteLine();
try
{
Console.WriteLine("Linear search 101:");
Console.WriteLine(collection.LinearSearch(101));
Console.WriteLine("Linear search 22:");
Console.WriteLine(collection.LinearSearch(22));
Console.WriteLine("Linear search 301:");
Console.WriteLine(collection.LinearSearch(301));
Console.WriteLine();
Console.WriteLine("Binary search 101:");
Console.WriteLine(collection.BinarySearch(101));
Console.WriteLine("Linear search 22:");
Console.WriteLine(collection.LinearSearch(22));
Console.WriteLine("Linear search 301:");
Console.WriteLine(collection.LinearSearch(301));
Console.WriteLine();
Console.WriteLine("Shuffle:");
collection.Shuffle();
collection1.Shuffle();
collection.PrintAllItemsOnConsole();
Console.WriteLine();
Console.WriteLine("Shuffle again:");
collection.Shuffle();
collection.PrintAllItemsOnConsole();
collection1.Shuffle();
collection1.PrintAllItemsOnConsole();
}
catch (KeyNotFoundException error)
{
Console.WriteLine(error.Message);
}
}
catch (NotImplementedException err)
{
Console.Write("\n" + err.Message);
}
}