binaryinsertionsorter.cs

来自「Data Structures and Algorithms with Obj」· CS 代码 · 共 42 行

CS
42
字号
namespace Opus6
{
    using System;

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

        protected override void Sort()
        {
            for (int num1 = 1; num1 < base.n; num1++)
            {
                ComparableObject obj1 = base.array[num1];
                int num2 = 0;
                int num3 = num1;
                while (num2 < num3)
                {
                    int num4 = (num2 + num3) / 2;
                    if (obj1 >= base.array[num4])
                    {
                        num2 = num4 + 1;
                    }
                    else
                    {
                        num3 = num4;
                    }
                }
                for (int num5 = num1; num5 > num2; num5--)
                {
                    this.Swap(num5 - 1, num5);
                }
            }
        }

    }
}

⌨️ 快捷键说明

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