コード例 #1
0
        public void BubbleSortTest()
        {
            int[][] arr = new int[5][]
            {
                new int[3] {
                    10, 5, 2
                },
                new int[] { 2, 5, 7, 1, 2 },
                new int[] { 14, 5, Int32.MaxValue, 22, 4 },
                new int[] { 7, 91 },
                new int[] { 2, 4, 5, 6, 12 }
            };
            JaggedArray jaggedArray = new JaggedArray(arr);

            int[][] arrDeCreaseMax = new int[5][]
            {
                new int[] { 14, 5, Int32.MaxValue, 22, 4 },
                new int[] { 7, 91 },
                new int[] { 2, 4, 5, 6, 12 },
                new int[3] {
                    10, 5, 2
                },
                new int[] { 2, 5, 7, 1, 2 }
            };


            jaggedArray.BubbleSortByDecreaseMaxElement();
            Assert.IsTrue(jaggedArray.EqualsArray(arrDeCreaseMax));

            jaggedArray.BubbleSortByIncreaseMaxElement();
            Array.Reverse(arrDeCreaseMax);
            Assert.IsTrue(jaggedArray.EqualsArray(arrDeCreaseMax));
        }