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); }
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)); }
public static void Sort(ISortable[] sortables, ISortingMethod sortingMethod) { sortingMethod.Sort(sortables); }
private SortTemplate(ISortingMethod <T> sortingMethod) { _sortingMethod = sortingMethod; }