Re: A89: Re: Re: Folder List
[Prev][Next][Index][Thread]
Re: A89: Re: Re: Folder List
Hi!
You asked me about gap in ShellSort? OK, here is an implementation,
look and see:
void qsort(void *list,int num_items,int size,long(*cmp_func)(void*,void*))
{
unsigned gap,byte_gap,i,j;
char *p,*a,*b,temp;
for (gap=num_items>>1;gap>0;gap>>=1)
{
byte_gap=gap*size;
for(i=byte_gap;i<num_items*size;i+=size)
for(p=(char*)list+i-byte_gap;p>=(char*)list;p-=byte_gap)
{
a=p; b=p+byte_gap;
if(cmp_func(a,b)<=0) break;
for(j=size;j;j--) temp=*a,*a++=*b,*b++=temp;
}
}
}
Zeljko Juric
Follow-Ups: