1: shell (n, comp, exch)
2: int (*comp)(), (*exch)();
3: /* SORTS UP. IF THERE ARE NO EXCHANGES (IEX=0) ON A SWEEP
4: THE COMPARISON GAP (IGAP) IS HALVED FOR THE NEXT SWEEP */
5: {
6: int igap, iplusg, iex, i, imax;
7: igap=n;
8: while (igap > 1)
9: {
10: igap /= 2;
11: imax = n-igap;
12: do
13: {
14: iex=0;
15: for(i=0; i<imax; i++)
16: {
17: iplusg = i + igap;
18: if ((*comp) (i, iplusg) ) continue;
19: (*exch) (i, iplusg);
20: iex=1;
21: }
22: } while (iex>0);
23: }
24: }
Defined functions
shell
defined in line
1; used 3 times