コード例 #1
0
        public void SortTest_DESC_DuplicateKey()
        {
            String[] a = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "3", "4", "5", "3", "4", "5", "3", "4", "5" };
            Shuffle.Do(a);

            Assert.IsFalse(SortHelper.IsSorted(a, SortOrder.DESC));
            Quick3WaySort.Sort(a, SortOrder.DESC);
            Assert.IsTrue(SortHelper.IsSorted(a, SortOrder.DESC));
        }
コード例 #2
0
        public void SortTest()
        {
            String[] a = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
            Shuffle.Do(a);

            Assert.IsFalse(SortHelper.IsSorted(a));
            Quick3WaySort.Sort(a);
            Assert.IsTrue(SortHelper.IsSorted(a));
        }
コード例 #3
0
        public void TestCaseDescending()
        {
            SampleArray <int> .Get(out int[] arr, out int[] arrCopy, () => _random.Next(0, 100));

            Array.Sort(arrCopy, new Comparison <int>((x, y) => y.CompareTo(x)));
            var sort = new Quick3WaySort <int>(Comparer <int> .Create(new Comparison <int>((x, y) => y.CompareTo(x))));

            sort.Sort(arr);
            Assert.Equal(arr, arrCopy);
        }
コード例 #4
0
        public void TestCaseAscending()
        {
            SampleArray <int> .Get(out int[] arr, out int[] arrCopy, () => _random.Next(0, 100));

            Array.Sort(arrCopy);
            var sort = new Quick3WaySort <int>();

            sort.Sort(arr);
            Assert.Equal(arr, arrCopy);
        }
コード例 #5
0
        public void SortWithComparerTest_DESCOrder_NullComparer()
        {
            Point[] points = new Point[10];
            for (int i = 0; i < 10; i++)
            {
                points[i] = new Point(i, 10 - i);
            }

            Quick3WaySort.Sort(points, null, SortOrder.DESC);
        }
コード例 #6
0
        public void SortWithComparerTest_DESC()
        {
            Point[] points = new Point[10];
            for (int i = 0; i < 10; i++)
            {
                points[i] = new Point(i, 10 - i);
            }
            Shuffle.Do(points);

            Assert.IsFalse(SortHelper.IsSorted(points, Point.X_ORDER, SortOrder.DESC));
            Quick3WaySort.Sort(points, Point.X_ORDER, SortOrder.DESC);
            Assert.IsTrue(SortHelper.IsSorted(points, Point.X_ORDER, SortOrder.DESC));
        }
コード例 #7
0
ファイル: Sort.cs プロジェクト: dancrowley303/Algo
        public void Quick3WaySort()
        {
            var quickSort = new Quick3WaySort <byte>();
            var byteCount = 1024;
            var bytes     = new byte[byteCount];
            var rnd       = new Random();

            for (var i = 0; i < byteCount; i++)
            {
                bytes[i] = (byte)(rnd.Next() % 3);
            }
            quickSort.Go(bytes);
            Assert.IsTrue(quickSort.IsSorted(bytes));
        }
コード例 #8
0
        public void SortWithComparerTest_DESC_DuplicateKey()
        {
            Point[] points = new Point[19];
            for (int i = 0; i < 10; i++)
            {
                points[i] = new Point(i, 10 - i);
            }
            for (int i = 0; i < 3; i++)
            {
                for (int j = 3; j <= 5; j++)
                {
                    points[10 + i * 3 + j - 3] = new Point(j, 10 - i);
                }
            }
            Shuffle.Do(points);

            Assert.IsFalse(SortHelper.IsSorted(points, Point.X_ORDER, SortOrder.DESC));
            Quick3WaySort.Sort(points, Point.X_ORDER, SortOrder.DESC);
            Assert.IsTrue(SortHelper.IsSorted(points, Point.X_ORDER, SortOrder.DESC));
        }
コード例 #9
0
 public void SortWithComparerTest_DESCOrder_NullArray()
 {
     Quick3WaySort.Sort(null, Point.X_ORDER, SortOrder.DESC);
 }
コード例 #10
0
 public void SortWithComparerTest_NullArray()
 {
     Quick3WaySort.Sort(null, Point.X_ORDER);
 }
コード例 #11
0
 public void SortTest_DESCOrder_NullArray()
 {
     Quick3WaySort.Sort(null, SortOrder.DESC);
 }
コード例 #12
0
 public void SortTest_NullArray()
 {
     Quick3WaySort.Sort(null);
 }