- 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 ShakerSort : SwapSorter
{
public ShakerSort() : base() {}
public ShakerSort(IComparer comparer, ISwap swapper)
:base(comparer,swapper)
{
}
public override void Sort(IList list)
{
int i;
int j;
int k;
int min;
int max;
i = 0;
k = list.Count-1;
while (i < k)
{
min = i;
max = i;
for (j=i+1;j<=k;j++)
{
if (Comparer.Compare(list[j], list[min])<0)
{
min = j;
}
if (Comparer.Compare(list[j], list[max])>0)
{
max = j;
}
}
Swapper.Swap(list, min, i);
if (max == i)
{
Swapper.Swap(list, min,k);
}
else
{
Swapper.Swap(list, max, k);
}
i++;
k--;
}
}
}
}
|
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.