📄 selectsort.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
namespace GraphicsSort
{
public class SelectSort:SortBase, ISortable
{
public SelectSort(int[] initList, System.Windows.Forms.Control ctlToDraw)
: base("SelectSort",initList, ctlToDraw)
{
}
#region ISortable 成员
public void Sort()
{
SwapCount = 0;
IsComplete = false;
for (int i = 0; i < list.Length - 1; i++)
{
int pos = i;
for (int j = i + 1; j < list.Length; j++)
{
if (list[pos] > list[j])
pos = j;
}
int tmp = list[i];
list[i] = list[pos];
list[pos] = tmp;
SwapCount++;
foreach (StepComplete sc in stepComplete.GetInvocationList())
{
sc(ctl, e);
}
}
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 + -