Пример #1
0
        public void Remove(int number)
        {
            if (listOfNumbers.Count > 4)
            {
                sortStrategy = new MergeSort();
            }
            else
            {
                sortStrategy = new QuickSort();
            }

            doStats();
        }
Пример #2
0
        public void Add(int number)
        {
            listOfNumbers.Add(number);

            if (listOfNumbers.Count > 10)
            {
                sortStrategy = new MergeSort();
            }
            else
            {
                sortStrategy = new QuickSort();
            }
            doStats();
        }
Пример #3
0
        private static ISortingStrategy GetSortingOption(ObjectToSort objectToSort)
        {
            ISortingStrategy sortingStrategy = null;

            switch (objectToSort)
            {
            case ObjectToSort.StudentNumber:
                sortingStrategy = new MergeSort();
                break;

            case ObjectToSort.RailwayPassengers:
                sortingStrategy = new HeapSort();
                break;

            case ObjectToSort.CountyResidents:
                sortingStrategy = new QuickSort();
                break;

            default:
                break;
            }
            return(sortingStrategy);
        }