コード例 #1
0
ファイル: Program.cs プロジェクト: ChegnduJackli/Projects
 static void Main(string[] args)
 {
     SortedList sortList = new SortedList();
     sortList.Add("A");
     sortList.Add("B");
     sortList.Add("V");
     sortList.Add("S");
     sortList.SetStrategy(new ShellSort());
     sortList.Sort();
     sortList.Display();
     Console.ReadKey();
 }
コード例 #2
0
        static void Main(string[] args)
        {
            SortedList studentRecords = new SortedList();

            studentRecords.Add("John");
            studentRecords.Add("Peter");
            studentRecords.Add("George");
            studentRecords.Add("Paul");
            studentRecords.Add("Martin");

            studentRecords.SetSortingStrategy(new Quicksort());
            studentRecords.Sort();

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

            Console.Read();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: atree1987/MyWorks
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        static void Main()
        {
            // Two contexts following different strategies
            SortedList studentRecords = new SortedList();

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

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

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

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

            // Wait for user
            Console.ReadKey();
        }
コード例 #4
0
        private static void Main()
        {
            // Two contexts following different strategies
            SortedList studentRecords = new SortedList();

            studentRecords.Add("John");
            studentRecords.Add("Peter");
            studentRecords.Add("George");
            studentRecords.Add("Paul");
            studentRecords.Add("Martin");

            studentRecords.SetSortingStrategy(new Quicksort());
            studentRecords.Sort();

            studentRecords.SetSortingStrategy(new Shellsort());
            studentRecords.Sort();

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

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