Exemple #1
0
        public static void SortingUnitDemo()
        {
            Console.WriteLine("Please input text:");
            string[] array1 = Console.ReadLine().Split(new char[] { ' ' },
                                                       StringSplitOptions.RemoveEmptyEntries);
            var comparer = new Func <string, string, int>(StringComparer);
            var su1      = new SortingUnit();

            su1.Finished += SortFinished;
            su1.CustomSortThreaded(array1, comparer);
        }
Exemple #2
0
        public static void ConsoleInterface()
        {
            //Initialization of the first array
            Random rand = new Random();

            string[] a = new string[100000];
            Console.WriteLine("Array1 before sorting:");
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = "";
                int temp = rand.Next(0, 10);
                for (int k = 0; k < temp; k++)
                {
                    a[i] += i;
                }
                if (i < 100)
                {
                    Console.Write(a[i] + "; ");
                }
            }
            //Initialization of the second array
            float[] a2 = new float[1000];
            Console.WriteLine(Environment.NewLine + "Array2 before sorting:");
            for (int i = 0; i < a2.Length; i++)
            {
                a2[i] = rand.Next(0, 10) / 10f;
                if (i < 100)
                {
                    Console.Write(a[i] + "; ");
                }
            }
            //Sorting two arrays asynchronously
            SortingUnit <string> .NewThreadSort(a, Comparison <string> .CompareStringByLength);

            SortingUnit <float> .NewThreadSort(a2, Comparison <float> .CompareFloat);

            //Printing sorted arrays
            Console.WriteLine(Environment.NewLine + "Array1 after sorting:");
            for (int i = 0; i < 100; i++)
            {
                Console.Write(a[i] + "; ");
            }
            Console.WriteLine(Environment.NewLine + "Array2 after sorting:");
            foreach (var item in a2)
            {
                Console.Write(item + "; ");
            }
        }
Exemple #3
0
        static void Main()
        {
            double selection;

            do
            {
                Console.WriteLine("4,1 CUSTOM SORT.");
                Console.WriteLine("4,2 CUSTOM SORT DEMO.");
                Console.WriteLine("4,3 SORTING UNIT.");
                Console.WriteLine("4,4 NUMBER ARRAY SUM.");
                Console.WriteLine("4,5 TO INT OR NOT TO INT?");
                Console.WriteLine("4,6 I SEEK YOU.");
                Console.WriteLine("0 Exit.");
                Console.WriteLine();
                if (double.TryParse(Console.ReadLine(), out selection))
                {
                    switch (selection)
                    {
                    case 4.1:
                        CustomSort.ShowFirstTask();
                        break;

                    case 4.2:
                        CustomSort.ShowSecondTask();
                        break;

                    case 4.3:
                        SortingUnit.Show();
                        break;

                    case 4.4:
                        NumberArraySum.ShowFourthTask();
                        break;

                    case 4.5:
                        NumberArraySum.ShowFifthTask();
                        break;

                    case 4.6:
                        ISeekYou.Show();
                        break;

                    case 0:
                        break;
                    }
                }
            } while (selection != 0);
        }
Exemple #4
0
 public static void CustomSort <T>(T[] array, Func <T, T, int> comparer)
 {
     SortingUnit.CustomSort(array, comparer);
 }