// the bits macro returns the z bits that are y bits from the right in // the number x --- taken from Algorithms by Sedgewick #define bits(x,y,z) ((unsigned) ( (((unsigned)(x)) >> (y)) & ~(~0 << (z)) )) #define WORDSIZE 8 // number of "chunks" at a time #define WORDS_PER_INT 4 #define WORD_VALUES (1 << WORDSIZE) // 2^WORDSIZE void RadixSort(Vector & a,int n) // precondition: n = # of elements of a // // from Sedgewick, (code in book is incorrect!!) { static Vector extra(MAX); // extra storage static Vector count(WORD_VALUES); // once per program int j,k,radix=WORD_VALUES; // see Sedgewick for explanation (yeah, right) for(j=0;j=0;k--){ extra[--count[bits(a[k],j*WORDSIZE,WORDSIZE)]] = a[k]; } for(k=0;k