示例#1
0
        public void Run()
        {
            Console.WriteLine("Choose file:");   // Prompt
            Console.WriteLine("1 - tiny.txt");   // Prompt
            Console.WriteLine("2 - words3.txt"); // Prompt
            Console.WriteLine("or quit");        // Prompt

            var fileNumber = Console.ReadLine();
            var fieName    = string.Empty;

            switch (fileNumber)
            {
            case "1":
                fieName = "tiny.txt";
                break;

            case "2":
                fieName = "words3.txt";
                break;

            case "quit":
                return;

            default:
                return;
            }


            var @in   = new In($"Files\\Sorting\\{fieName}");
            var words = @in.ReadAllStrings();

            var list = words.Select(word => new StringComparable(word)).ToList();

            var listComparable  = list.Cast <IComparable>().ToList();
            var arrayComparable = list.Cast <IComparable>().ToArray();
            var listStrings     = words.ToList();


            // sort list
            MergeX.Sort(listComparable);
            // print results.
            AbstractSort.Show(listComparable);

            Console.WriteLine("-----------------------------------------------------");

            // sort array
            MergeX.Sort(arrayComparable);
            // print results.
            AbstractSort.Show(arrayComparable);

            Console.WriteLine("-----------------------------------------------------");

            // sort list
            MergeX <string> .Sort(listStrings, new StringComparer());

            // print results
            MergeX <string> .Show(listStrings);

            Console.ReadLine();
        }
示例#2
0
        public void Run()
        {
            Console.WriteLine("Choose file:");   // Prompt
            Console.WriteLine("1 - tiny.txt");   // Prompt
            Console.WriteLine("2 - words3.txt"); // Prompt
            Console.WriteLine("or quit");        // Prompt

            var    fileNumber = Console.ReadLine();
            string fieName;

            switch (fileNumber)
            {
            case "1":
                fieName = "tiny.txt";
                break;

            case "2":
                fieName = "words3.txt";
                break;

            case "quit":
                return;

            default:
                return;
            }


            var @in   = new In(string.Format("Files\\Sorting\\{0}", fieName));
            var words = @in.ReadAllStrings();

            var list = words.Select(word => new StringComparable(word)).ToList();

            var listComparable  = list.Cast <IComparable>().ToList();
            var arrayComparable = list.Cast <IComparable>().ToArray();
            var listStrings     = words.ToList();

            // sort list
            Heap.Sort(listComparable);
            // print results.
            AbstractSort.Show(listComparable);

            Console.ReadLine();
        }
示例#3
0
 public void SetUp()
 {
     elemSort = new SortingNetwork <int>();
 }
示例#4
0
 public NamedSort(string name, AbstractSort sorter)
 {
     Name    = name;
     _sorter = sorter;
 }