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

📄 twowaymergesorter.cs

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

    [Version("$Id: TwoWayMergeSorter.cs,v 1.3 2001/09/11 12:04:04 brpreiss Exp $"), Copyright("Copyright (c) 2001 by Bruno R. Preiss, P.Eng.")]
    public class TwoWayMergeSorter : AbstractSorter
    {
        public static void Main()
        {
            AbstractSorter.TestSorter(new TwoWayMergeSorter(), 0x2710, 0x7b);
        }

        protected void Merge(int left, int middle, int right)
        {
            int num1 = left;
            int num2 = left;
            int num3 = middle + 1;
            while ((num2 <= middle) && (num3 <= right))
            {
                if (base.array[num2] < base.array[num3])
                {
                    this.tempArray[num1++] = base.array[num2++];
                }
                else
                {
                    this.tempArray[num1++] = base.array[num3++];
                }
            }
            while (num2 <= middle)
            {
                this.tempArray[num1++] = base.array[num2++];
            }
            for (num1 = left; num1 < num3; num1++)
            {
                base.array[num1] = this.tempArray[num1];
            }
        }

        protected override void Sort()
        {
            this.tempArray = new ComparableObject[base.n];
            this.Sort(0, base.n - 1);
            this.tempArray = null;
        }

        protected void Sort(int left, int right)
        {
            if (left < right)
            {
                int num1 = (left + right) / 2;
                this.Sort(left, num1);
                this.Sort(num1 + 1, right);
                this.Merge(left, num1, right);
            }
        }


        private ComparableObject[] tempArray;
    }
}

⌨️ 快捷键说明

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