Пример #1
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");

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

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

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

            Console.ReadLine();
        }
Пример #2
0
        public static void Execute_Example()
        {
            SortedList studentRecords = new SortedList();

            studentRecords.Add("Konrad");
            studentRecords.Add("Marcin");
            studentRecords.Add("Mateusz");
            studentRecords.Add("Jakub");

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

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

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

            // Wait for user
            Console.ReadKey();
        }
        public StrategyExample1()
        {
            // 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
        static void Main(string[] args)
        {
            // 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();

            Console.WriteLine("Press any key to exit...");
            Console.Read();
        }
Пример #5
0
        static void Main(string[] args)
        {
            var sortedList = new SortedList();
            sortedList.Add("John Doe");
            sortedList.Add("Tommy Toe");
            sortedList.Add("John Smith");

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

            Console.WriteLine(sortedList);

            Console.ReadLine();
        }
Пример #6
0
        static void Main(string[] args)
        {
            var sortedList = new SortedList();

            sortedList.Add("John Doe");
            sortedList.Add("Tommy Toe");
            sortedList.Add("John Smith");

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

            Console.WriteLine(sortedList);

            Console.ReadLine();
        }