Beispiel #1
0
        public static void Sort <T>(T[] arrayForSort, ISortingMethod sortingMethod) where T : IComparable <T>
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            Count = sortingMethod.Sort(arrayForSort);
            stopWatch.Stop();
            TimeSpan timeSpan = stopWatch.Elapsed;

            Time = string.Format("{0}:{1}:{2}:{3}", timeSpan.Minutes, timeSpan.Seconds, timeSpan.Milliseconds, timeSpan.Ticks);
        }
Beispiel #2
0
        public IEnumerable <T> Sort(IEnumerable <T> array, SortingMethodEnum sortingMethod, ComparerEnum comparerEnum)
        {
            IComparer <T> comparer = ComparerFactory <T> .Create(comparerEnum);

            switch (sortingMethod)
            {
            case SortingMethodEnum.BubbleSort:
                _sortingMethod = new BubbleSort <T>();
                break;

            case SortingMethodEnum.QuickSort:
                _sortingMethod = new QuickShort <T>();
                break;
            }
            return(_sortingMethod.Sort(array, comparer));
        }
Beispiel #3
0
 public static void Sort(ISortable[] sortables, ISortingMethod sortingMethod)
 {
     sortingMethod.Sort(sortables);
 }
Beispiel #4
0
 private SortTemplate(ISortingMethod <T> sortingMethod)
 {
     _sortingMethod = sortingMethod;
 }