- aop.zip
- antlr.runtime.dll
- Benchmarking.sln
- Benchmarking
- Client
- CommandUI
- Common.Logging.dll
- Core
- MyApplication.CommandClient
- MyApplication.CommandCore
- Sorting
- Spring.Aop.dll
- Spring.Core.dll
|
//This is an unedited source code from:
//http://www.codeproject.com/cs/algorithms/cssorters.asp
//Article content copyright Jonathan de Halleux, Marc Clifton, Robert Rohde, 2004
//everything else Copyright � CodeProject, 1999-2007.
using System;
using System.Collections;
namespace NSort
{
public class ShellSort : SwapSorter
{
public ShellSort() : base() {}
public ShellSort(IComparer comparer, ISwap swapper)
: base(comparer,swapper)
{}
public override void Sort(IList list)
{
int h;
int i;
int j;
object b;
bool loop=true;
h = 1;
while (h * 3 + 1 <= list.Count)
{
h = 3 * h + 1;
}
while (h > 0)
{
for (i=h-1;i<list.Count;i++)
{
b = list[i];
j = i;
loop=true;
while (loop)
{
if (j>=h)
{
if (Comparer.Compare(list[j - h], b)>0)
{
Swapper.Set(list, j, j-h);
j = j - h;
}
else
{
loop=false;
}
}
else
{
loop=false;
}
}
Swapper.Set(list, j, b);
}
h = h / 3;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.