Searching an array index


function SearchIndex( key : typekey ) : BucketAddress; var low, high, j : integer; begin low := 0; high := n; {*** highest index entry ***} while high-low > 1 do begin j := (high+low) div 2; if key <= index[j].k then high := j else low := j end; SearchIndex := index[high].BuckAddr end;

Pascal source (343.index.p)



© Addison-Wesley Publishing Co. Inc.