示例#1
0
        static void RunListMergeSort()
        {
            Console.WriteLine("SORT some lists");

            LinkedList<int> ll = new LinkedList<int>();
            Console.WriteLine("List of one");
            ll = new LinkedList<int>();
            ll.Insert(5);
            ll.ConsoleOutput();
            ll.Sort();
            ll.ConsoleOutput();

            Console.WriteLine("List of two");
            ll = new LinkedList<int>();
            ll.Insert(5); ll.Insert(25);
            ll.ConsoleOutput();
            ll.Sort();
            ll.ConsoleOutput();

            Console.WriteLine("List of two");
            ll = new LinkedList<int>();
            ll.Insert(255); ll.Insert(44);
            ll.ConsoleOutput();
            ll.Sort();
            ll.ConsoleOutput();

            Console.WriteLine("List of three");
            ll = new LinkedList<int>();
            ll.Insert(255); ll.Insert(44); ll.Insert(123);
            ll.ConsoleOutput();
            ll.Sort();
            ll.ConsoleOutput();

            Console.WriteLine("List of many");
            ll = new LinkedList<int>();
            ll.Insert(5); ll.Insert(25); ll.Insert(-1); ll.Insert(12345); ll.Insert(75788933); ll.Insert(9876);
            ll.Insert(125); ll.Insert(3543525); ll.Insert(647); ll.Insert(854); ll.Insert(234);
            ll.Insert(-255); ll.Insert(1); ll.Insert(2); ll.Insert(12346); ll.Insert(75788932);
            ll.Insert(9877); ll.Insert(9875); ll.Insert(12343); ll.Insert(23); ll.Insert(0);
            ll.ConsoleOutput();
            ll.Sort();
            ll.ConsoleOutput();
        }