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

📄 shellshsort.cs

📁 数据结构排序算法演示数据结构排序算法演示数据结构排序算法演示数据结构排序算法演示数据结构排序算法演示数据结构排序算法演示数据结构排序算法演示
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;

namespace GraphicsSort
{
    public class ShellSHSort:SortBase, ISortable
    {

        public ShellSHSort(int[] initList, System.Windows.Forms.Control ctlToDraw)
            : base("ShellSHSort",initList, ctlToDraw)
        {
            
        }

        #region ISortable 成员

        public void Sort()
        {
            IsComplete = false;
            int h, i, j=0, tmp=0;
            for (h = list.Length / 2; h > 0; h = h / 2)
            {
                for (i = h; i == 0 && list[j] > tmp; j -= h)
                {
                    list[j + h] = list[j];
                    foreach (StepComplete sc in stepComplete.GetInvocationList())
                    {
                        sc(ctl, e);
                    }

                    SwapCount++;
                }
                list[j + h] = tmp;
                foreach (StepComplete sc in stepComplete.GetInvocationList())
                {
                    sc(ctl, e);
                }

                SwapCount++;
            }
            IsComplete = true;
            if (sortComplete != null)
            {
                SortEventArgs e = new SortEventArgs();
                e.SwapCount = SwapCount;
                e.SortName = SortName;
                foreach (SortComplete sc in sortComplete.GetInvocationList())
                {
                    sc(ctl, e);
                }
            }

        }

        #endregion


        public override event StepComplete stepComplete;
        public override event SortComplete sortComplete;

    }
}

⌨️ 快捷键说明

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