|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - downloadIndex: ┃ T s ┃
Length: 978 (0x3d2) Types: TextFile Names: »sort1.c«
└─⟦87ddcff64⟧ Bits:30001253 CPHDIST85 Tape, 1985 Autumn Conference Copenhagen └─ ⟦this⟧ »cph85dist/wirewrap/sort1.c«
/******************************************************* * Batcher's method sort by signalname. * * Reference: Knuth Sorting & Searching, Section 5.2.2 * *******************************************************/ #include "wirewrap.h" sort1() { struct pin tempin; int p,q,r,d,n,i,j,m; /*Find the 'middle' of the array.*/ n = nextfree; i = 1; j = 2; while(j < n) { i = j; j = j+j; } m = i; /*m is the middle of the array*/ /* Batcher's method*/ p = m; while(p > 0) { q = m; r = 0; d =p; for(;;) { for(i= 0;i < n-d;i++) { if ( (i&p) == r) if(namecmp(pinarray[i].signalname->signalname, pinarray[i+d].signalname->signalname)>0) { tempin = pinarray[i+d]; pinarray[i+d] = pinarray[i]; pinarray[i] = tempin; } } if(p != q) { d = q - p; q = q/2; r = p; } else break; } p = p/2; } }