1: # include "refer.h"
   2: static int *coord 0;
   3: int hh[NQUERY];
   4: extern int *hfreq, hfrflg, hcomp(), hexch();
   5: extern int nhash;
   6: 
   7: doquery(nitem)
   8: {
   9:     long k;
  10:     int nf 0;
  11:     register nterm 0, i, g, j;
  12:     long lp;
  13:     long getl();
  14:     unsigned getw();
  15: 
  16:     if (coord==0)
  17:         coord = zalloc(lmaster, sizeof(lmaster));
  18:     if (coord==0)
  19:         err("No space for coord list",0);
  20:     for(i=0; i<nitem; i++)
  21:         hh[i] = hash(qitem[i])%nhash;
  22:     /* if possible, sort query into decreasing frequency of hashes */
  23:     if (hfrflg)
  24:         shell (nitem, hcomp, hexch);
  25:     lp = hpt [hh[0]];
  26:     fseek(fb,lp,0);
  27:     for(i=0; i<lmaster; i++)
  28:     {
  29:         coord[i]=1;
  30:         if (iflong) {
  31:             if ((master.b[i] = getl(fb)) == -1L) break;
  32:         } else {
  33:             if ((master.a[i] = getw(fb)) == -1) break;
  34:         }
  35:     }
  36:     if (i==lmaster)
  37:         fprintf(stderr,"master list too short\n");
  38:     nf= i;
  39:     for(nterm=1; nterm<nitem; nterm++)
  40:     {
  41:         lp = hpt[hh[nterm]];
  42:         fseek(fb, lp, 0);
  43:         g=j=0;
  44:         while (1)
  45:         {
  46:             if (iflong)
  47:                 k = getl(fb);
  48:             else
  49:                 k = getw(fb);
  50:             if (k== -1) break;
  51:             while (j<nf && (iflong?master.b[j]:master.a[j])<k)
  52:             {
  53:                 if (coord[j] <= nterm)
  54:                     j++;
  55:                 else
  56:                 {
  57:                     if (iflong)
  58:                         master.b[g] = master.b[j];
  59:                     else
  60:                         master.a[g] = master.a[j];
  61:                     coord[g++] = coord[j++];
  62:                     continue;
  63:                 }
  64:             }
  65:             if (j>=nf) break;
  66:             if ((iflong? master.b[j]: master.a[j]) == k)
  67:             {
  68:                 if (iflong)
  69:                     master.b[g]=k;
  70:                 else
  71:                     master.a[g]=k;
  72:                 coord[g++] = coord[j++]+1;
  73:             }
  74:         }
  75:         nf = g;
  76:     }
  77:     return(nf);
  78: }
  79: long
  80: getl(fb)
  81: FILE *fb;
  82: {
  83:     int x[2];
  84:     long *lp;
  85:     x[0] = getw(fb);
  86:     x[1] = getw(fb);
  87:     lp= x;
  88:     return(*lp);
  89: }
  90: hcomp( n1, n2)
  91: {
  92:     return (hfreq[hh[n1]]<=hfreq[hh[n2]]);
  93: }
  94: hexch( n1, n2 )
  95: {
  96:     int t;
  97:     t = hh[n1];
  98:     hh[n1] = hh[n2];
  99:     hh[n2] = t;
 100: }

Defined functions

doquery defined in line 7; used 1 times
getl defined in line 79; used 3 times
hcomp defined in line 90; used 2 times
  • in line 4, 24
hexch defined in line 94; used 2 times
  • in line 4, 24

Defined variables

coord defined in line 2; used 9 times
hh defined in line 3; used 9 times
Last modified: 1981-11-19
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 866
Valid CSS Valid XHTML 1.0 Strict