Beispiel #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();
            }
        }
 private void GenerateArray_Click(object sender, RoutedEventArgs e)
 {
     randomArray.Clear();
     originList.Clear();
     insertSortList.Clear();
     shellSortList.Clear();
     selectSortList.Clear();
     HeapSortList.Clear();
     bubbleSortList.Clear();
     quickSortList.Clear();
     quickSortUseThreadsList.Clear();
     defaultSortList.Clear();
     Task.Run(
         () => {
         Random ran = new Random();
         for (int i = 0; i < arrayLength; i++)
         {
             randomArray.Add(ran.Next(0, 1000));
         }
         randomList = randomArray.ConvertAll(new Converter <double, ObservableValue>(x => { return(new ObservableValue(x)); }));
         originList.AddRange(randomList);
         insertSortList.AddRange(randomList);
         shellSortList.AddRange(randomList);
         selectSortList.AddRange(randomList);
         HeapSortList.AddRange(randomList);
         bubbleSortList.AddRange(randomList);
         quickSortList.AddRange(randomList);
         quickSortUseThreadsList.AddRange(randomList);
         defaultSortList.AddRange(randomList);
     });
 }
Beispiel #3
0
        public static void TestArray_List(int seed)
        {
            int         n       = 12;
            MyDataArray myArray = new MyDataArray(n, seed);

            Console.WriteLine("---Array---");
            myArray.Print(n);
            Console.WriteLine();
            Console.WriteLine("---HeapSortedArray---");
            HeapSortArray.HeapSortas(myArray);
            myArray.Print(n);
            Console.WriteLine();
            MyDataList myList = new MyDataList(n, seed);

            Console.WriteLine("---List---");
            myList.Print(n);
            Console.WriteLine();
            Console.WriteLine("---HeapSortedList---");
            HeapSortList.HeapSortas(myList);
            myList.Print(n);
            Console.WriteLine();
        }