|
|
DataMuseum.dkPresents historical artifacts from the history of: Commodore CBM-900 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Commodore CBM-900 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 529 (0x211)
Types: TextFile
Notes: UNIX file
Names: »shellsort.c«
└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
└─⟦f4b8d8c84⟧ UNIX Filesystem
└─⟦this⟧ »libc/gen/shellsort.c«
/*
* Shell sort with the calling sequence of
* qsort.
*/
#define A(v,i) ((v)+((i)*size))
shellsort(v, n, size, compar)
register char *v;
int (*compar)();
{
int gap, i;
register j;
for (gap = n/2; gap > 0; gap /= 2)
for (i = gap; i < n; i++)
for (j = i-gap; j>=0; j -= gap) {
if ((*compar)(A(v,j), A(v,j+gap)) <= 0)
break;
qexch(A(v,j), A(v,j+gap), size);
}
}
static
qexch(p1, p2, n)
register char *p1, *p2, n;
{
int t;
if (n)
do {
t = *p1;
*p1++ = *p2;
*p2++ = t;
} while (--n);
}