Exemple #1
0
 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();
 }
        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();
        }
Exemple #3
0
        /// <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();
        }
Exemple #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();
        }