示例#1
0
        public static void TestArray_ListFile(int seed)
        {
            int         n        = 12;
            string      filename = @"myTestArray.dat";
            MyFileArray myarray  = new MyFileArray(filename, n, seed);

            using (myarray.fs = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite))
            {
                Console.WriteLine("---FileArray---");
                myarray.Print(n);
                Console.WriteLine();
                Console.WriteLine("---HeapSortedFileArray---");
                HeapSortArray.HeapSortas(myarray);
                myarray.Print(n);
                Console.WriteLine();
            }
            filename = @"myTestList.dat";
            MyFileList mylist = new MyFileList(filename, n, seed);

            using (mylist.fs = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite))
            {
                Console.WriteLine("---FileList---");
                mylist.Print(n);
                Console.WriteLine();
                Console.WriteLine("---HeapSortedFileList---");
                HeapSortList.HeapSortas(mylist);
                mylist.Print(n);
                Console.WriteLine();
            }
        }
        public static void Test_D(int seed)
        {
            Console.WriteLine("---------------------------------------------");
            Console.WriteLine("Test D");

            Stopwatch sw = new Stopwatch();

            string filename = @"/home/justin/Projects/HeapSort_OP/HeapSort_OP/mydataarray.dat";

            sw.Start();
            Console.WriteLine("Size of {0} count was initialized in => {1}", n, sw.Elapsed);
            MyFileArray myfilearray = new MyFileArray(filename, n, seed);

            sw.Stop();

            sw.Start();

            using (myfilearray.fs = new FileStream(filename, FileMode.Open,
                                                   FileAccess.ReadWrite))
            {
                Console.WriteLine("\n FILE ARRAY \n");
                myfilearray.Print(n);
                Heapsort_D.HeapSort(myfilearray, n);

                myfilearray.PrintFromFile(n);
            }
            sw.Stop();

            Console.WriteLine("Test D success ");
            Console.WriteLine("Size of {0} count file was sorted in => {1}", n, sw.Elapsed);
            Console.WriteLine("---------------------------------------------");
        }