Beispiel #1
0
        public void TestMethodQuickSort()
        {
            var nums = new int[] { 3, 9, 2, 5, 6, 4, 11, 7, 12 };

            BinarySort.QuickSort(nums, 0, nums.Length - 1);
            CollectionAssert.AreEqual(new int[] { 2, 3, 4, 5, 6, 7, 9, 11, 12 }, nums);
        }
Beispiel #2
0
 //将绘制过程进行抽象出来
 public static void DrawElements(ref BinarySort <RenderObj> binarySort)
 {
     RenderObj[] objs = binarySort.meshes;
     for (int j = 0; j < binarySort.count; ++j)
     {
         Graphics.DrawMeshNow(objs[j].targetMesh, objs[j].localToWorldMatrices);
     }
 }
Beispiel #3
0
 public void TestHeapSort()
 {
     int[] data = new int[] { 5, 37, 1, 61, 11, 59, 48, 19 };
     BinarySort.HeapSort(data);
     foreach (int i in data)
     {
         Console.Write(i + " ");
     }
 }
Beispiel #4
0
 public void TestQuickSort()
 {
     int[] data = new int[] { 7, 3, 8, 2, 5, 6, 0, 1, 9, 4 };
     BinarySort.QuickSort(data, 0, 9);
     foreach (int i in data)
     {
         Console.Write(i + " ");
     }
 }
Beispiel #5
0
        public void TestSorting()
        {
            int[]      _testData = { 10, 0, 67, 44, 23, 5, 77 };
            BinarySort sortData  = new BinarySort();

            int[] _sortedData   = sortData.BubbleSortData(_testData);
            int[] _expectedData = { 0, 5, 10, 23, 44, 67, 77 };
            Assert.AreEqual(_expectedData, _sortedData);
        }
Beispiel #6
0
 public void TestMergeSort()
 {
     int[] data = new int[] { 10, 7, 2, 6, 2, 8, 9, 0, 15, 27, 11, 9 };
     int[] temp = new int[12];
     BinarySort.MergeSort(data, temp, 0, 11);
     foreach (int i in data)
     {
         Console.Write(i + " ");
     }
 }
Beispiel #7
0
 public static void InitSortMesh(int maximumDrawCall)
 {
     if (init)
     {
         return;
     }
     init = true;
     for (int i = 0; i < LayerCount; ++i)
     {
         sortObj[i] = new BinarySort <RenderObj>(maximumDrawCall);
     }
 }
Beispiel #8
0
 public static void InitSortMesh(int maximumDrawCall)
 {
     if (init)
     {
         return;
     }
     init = true;
     for (int i = 0; i < LAYERCOUNT; ++i)
     {
         sorts[i] = new BinarySort <RenderObject>(maximumDrawCall);
     }
 }
        public void TestSearching(bool expectedResult, int _min, int _max)
        {
            //int[] _testData = { 10, 0, 67, 44, 23, 5, 77 };
            int[] _testData = { 5 };
            //int[] _testData = { 5,10 };
            BinarySort sortData = new BinarySort();

            int[] _sortedData  = sortData.BubbleSortData(_testData);
            int   _searchValue = 5;
            //int _min = 0;
            //int _max = _testData.Length - 1;
            object actualResult = BinarySort.BinarySearch(_sortedData, _searchValue, _min, _max);

            Assert.AreEqual(expectedResult, actualResult);
        }
Beispiel #10
0
        private static void TestSort()
        {
            var arr = new int[] { 9, 8, 7, 6, 5, 4, 3, 2, 1 };

            BinarySort.Sort(arr);

            for (var i = 0; i < arr.Length; i++)
            {
                Console.Write(arr[i]);
            }
            Console.WriteLine();

            arr = new int[] { 3, 2, 1, 9, 8, 7, 6, 5, 4 };

            QuickSort.Sort(arr);

            for (var i = 0; i < arr.Length; i++)
            {
                Console.Write(arr[i]);
            }
            Console.WriteLine();
        }
Beispiel #11
0
 public void TestSwap()
 {
     int[] data = new int[] { 10, 7, 2, 6, 2, 8, 9, 0, 15, 27, 11, 9 };
     BinarySort.Swap(data, 0, 11);
     BinarySort.PrintArray(data);
 }