⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstractsorter.cs

📁 Data Structures and Algorithms with Object-Oriented Design Patterns in C# 这本书的范例代码dll自己反编译的source
💻 CS
字号:
namespace Opus6
{
    using System;

    [Copyright("Copyright (c) 2001 by Bruno R. Preiss, P.Eng."), Version("$Id: AbstractSorter.cs,v 1.6 2001/10/28 19:50:09 brpreiss Exp $")]
    public abstract class AbstractSorter : Sorter
    {
        protected AbstractSorter()
        {
        }

        protected abstract void Sort();
        public virtual void Sort(ComparableObject[] array)
        {
            this.n = array.Length;
            this.array = array;
            if (this.n > 0)
            {
                this.Sort();
            }
            this.array = null;
        }

        protected virtual void Swap(int i, int j)
        {
            ComparableObject obj1 = this.array[i];
            this.array[i] = this.array[j];
            this.array[j] = obj1;
        }

        public static void TestSorter(Sorter sorter, int n, int seed)
        {
            AbstractSorter.TestSorter(sorter, n, seed, 0);
        }

        public static void TestSorter(Sorter sorter, int n, int seed, int m)
        {
            RandomNumberGenerator.Seed = seed;
            ComparableObject[] objArray1 = new ComparableObject[n];
            for (int num1 = 0; num1 < n; num1++)
            {
                int num2 = (int) (2147483647 * RandomNumberGenerator.Next);
                if (m != 0)
                {
                    num2 = num2 % m;
                }
                objArray1[num1] = (ComparableObject) num2;
            }
            DateTime time1 = DateTime.Now;
            sorter.Sort(objArray1);
            TimeSpan span1 = (TimeSpan) (DateTime.Now - time1);
            Opus6.Console.WriteLine("{0} {1} {2} {3}", new object[] { sorter.GetType().FullName, n, seed, span1.TotalSeconds });
            for (int num3 = 1; num3 < n; num3++)
            {
                if (objArray1[num3] < objArray1[num3 - 1])
                {
                    Opus6.Console.WriteLine("FAILED");
                    return;
                }
            }
        }


        protected ComparableObject[] array;
        protected int n;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -