예제 #1
0
        public void SortArray <T>(T[] array, ComparisonDel <T> comparison) where T : IComparable <T>
        {
            T temp = default(T);

            string arrayType = array.ToString();

            if (comparison != null)
            {
                for (int i = 0; i < array.Length; i++)
                {
                    for (int j = i + 1; j < array.Length; j++)
                    {
                        if (comparison(array[i], array[j]))
                        {
                            temp     = array[i];
                            array[i] = array[j];
                            array[j] = temp;
                        }
                        Console.WriteLine($" - - - В массиве {arrayType} произошло сравнение {array[i]} и {array[j]}");

                        Thread.Sleep(50);
                    }
                }

                OnSorted?.Invoke(arrayType);
            }
        }
예제 #2
0
        public static T[] SortInIndividualThread <T>(T[] array, Func <T, T, int> comparer)
        {
            T[]    sortedArray = null;
            Thread th          = new Thread(
                () =>
            {
                sortedArray = Sort(array, comparer);
                OnSorted?.Invoke("Sort is done.");
            });

            th.Start();
            th.Join();
            return(sortedArray);
        }
예제 #3
0
 public void AssignSortedGroups(IList <TileGroup> groups)
 {
     _groups = groups;
     OnSorted?.Invoke(_groups);
 }