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

📄 heapsorter.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: HeapSorter.cs,v 1.3 2001/09/11 12:04:04 brpreiss Exp $")]
    public class HeapSorter : AbstractSorter
    {
        protected void BuildHeap()
        {
            for (int num1 = base.n / 2; num1 > 0; num1--)
            {
                this.PercolateDown(num1, base.n);
            }
        }

        public static void Main()
        {
            AbstractSorter.TestSorter(new HeapSorter(), 0x2710, 0x7b);
        }

        protected void PercolateDown(int i, int length)
        {
            while ((2 * i) <= length)
            {
                int num1 = 2 * i;
                if ((num1 < length) && (base.array[(num1 + 1) - 1] > base.array[num1 - 1]))
                {
                    num1++;
                }
                if (base.array[i - 1] >= base.array[num1 - 1])
                {
                    return;
                }
                this.Swap(i - 1, num1 - 1);
                i = num1;
            }
        }

        protected override void Sort()
        {
            this.BuildHeap();
            for (int num1 = base.n; num1 >= 2; num1--)
            {
                this.Swap(num1 - 1, 0);
                this.PercolateDown(1, num1 - 1);
            }
        }


        protected const int baseIndex = 1;
    }
}

⌨️ 快捷键说明

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