Пример #1
0
        static void Main(string[] args)
        {
            var context = new SortedList(new List<int> { 1, 4, 2, 6, 7, 3 }, new QuickSortStrategy());
            //var context = new SortedList(new List<int> { 1, 4, 2, 6, 7, 3 }, new MergeSortStrategy());
            //var context = new SortedList(new List<int> { 1, 4, 2, 6, 7, 3 }, new HeapSortStrategy());

            context.Sort();

            Console.ReadKey();
        }
Пример #2
0
        static void Main(string[] args)
        {
            SortedList students = new SortedList();
            students.Add("Rose");
            students.Add("Lily");
            students.Add("sunflower");

            students.SelectSortingAlgo(new MergeSort());
            students.Sort();

            students.SelectSortingAlgo(new BubbleSort());
            students.Sort();
        }
Пример #3
0
        static void Main(string[] args)
        {
            SortedList list = new SortedList();

            list.Add("Martin");
            list.Add("Martin2");
            list.Add("Martin3");
            list.Add("Martin4");

            QuickSort sort = new QuickSort();
            list.SetSortStrategy(sort);

            list.Sort();

            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            SortedList list = new SortedList();
            list.Add("Jack");
            list.Add("Marry");
            list.Add("Lucy");
            list.Add("Amber");

            list.SetSortStrategy(new QuickSort());
            list.Sort();
            list.ShowInfo();

            list.SetSortStrategy(new ShellSort());
            list.Sort();
            list.ShowInfo();
        }
Пример #5
0
        static void Main(string[] args)
        {
            SortedList studentRecords = new SortedList();

            studentRecords.Add("Samual");
            studentRecords.Add("Jimmy");
            studentRecords.Add("Sandra");
            studentRecords.Add("Vivek");
            studentRecords.Add("Anna");

            #region 可隨意替換

            studentRecords.SetSortStrategy(new QuickSort());
            studentRecords.Sort();

            studentRecords.SetSortStrategy(new ShellSort());
            studentRecords.Sort();

            studentRecords.SetSortStrategy(new MergeSort());
            studentRecords.Sort();

            #endregion

            // Wait for user
            Console.ReadKey();
        }