/********************************************************************************************
ezwShell.cpp
Jim Millard
for CO311
EZwindows sort visualization for "Shell" Sort (modified bubble)
********************************************************************************************/
#include "ezwShell.h"
#include "ezwSwap.h"
void ShellSort(SimpleWindow& W, RaySegment* ptrR[], int A[], const int size, const short load)
{
bool DoneSorting = false;
int delta = size/2;
while (!DoneSorting)
{
DoneSorting = true;
for (int current = 0; current < size-delta; current++)
if (A[current] > A[current+delta])
{
DoneSorting = false;
Swap(A[current+delta],A[current]);
Swap(W, *ptrR[current+delta], *ptrR[current], load);
}
if (DoneSorting && (delta > 1))
{
DoneSorting = false;
delta /= 2;
}
}
return;
}