1: #ifndef lint
   2: static char *sccsid = "@(#)shell.c	4.1 (Berkeley) 5/6/83";
   3: #endif
   4: /*
   5:  * SORTS UP.
   6:  * IF THERE ARE NO EXCHANGES (IEX=0) ON A SWEEP
   7:  * THE COMPARISON GAP (IGAP) IS HALVED FOR THE NEXT SWEEP
   8:  */
   9: shell (n, comp, exch)
  10: int (*comp)(), (*exch)();
  11: {
  12:     int igap, iplusg, iex, i, imax;
  13:     igap=n;
  14:     while (igap > 1)
  15:     {
  16:         igap /= 2;
  17:         imax = n-igap;
  18:         do
  19:             {
  20:             iex=0;
  21:             for(i=0; i<imax; i++)
  22:             {
  23:                 iplusg = i + igap;
  24:                 if ((*comp) (i, iplusg) ) continue;
  25:                 (*exch) (i, iplusg);
  26:                 iex=1;
  27:             }
  28:         }
  29:         while (iex>0);
  30:     }
  31: }

Defined functions

Defined variables

sccsid defined in line 2; never used
Last modified: 1983-05-08
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 862
Valid CSS Valid XHTML 1.0 Strict