Category : C Source Code
Archive   : GHLNKLST.ZIP
Filename : LLSORT.C

 
Output of file : LLSORT.C contained in archive : GHLNKLST.ZIP
/*
* L I N K E D L I S T T O O L K I T
*
* Copyright (C) 1990 by Garyl Lee Hester
*
* llsort.c
*
* Shell Sort Routine
*/
#include
#include "ll.h"

/*
* MAKESORTPATOM - Answers a generic pointer p offset by o
*/
#define MAKESORTPATOM( p, o ) ((PGEN)( (char *)(p) + o ))

/*
* ll_sort - generic shell short for linked lists
*/
void ll_sort( PLLST pList,
short sDir,
unsigned usOffset,
COMPFUNC CompFunc
)
{
PATOM pOuter;
PATOM pInner;
PATOM pSelect;
short sCompRes;

for( pOuter = ll_first( pList );
pOuter && ll_next( pOuter );
pOuter = ll_next( pSelect )
)
{
pSelect = pOuter;
for( pInner = ll_next( pOuter );
pInner;
pInner = ll_next( pInner )
)
{
sCompRes = (*CompFunc)( MAKESORTPATOM( pSelect, usOffset ),
MAKESORTPATOM( pInner, usOffset )
);
if( ( sDir < 0 && sCompRes < 0 )
|| ( sDir > 0 && sCompRes > 0 )
)
pSelect = pInner;
}
if( pSelect != pOuter )
ll_swap( pList, pSelect, pOuter );

pOuter = ll_next( pSelect );
}
}


  3 Responses to “Category : C Source Code
Archive   : GHLNKLST.ZIP
Filename : LLSORT.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/