[Home]
[Chapter]
[Contents]
[Previous Algorithm]
[Next Algorithm]


Double hashing: search


function search( key : typekey; var r : dataarray ) : integer; var i, inc, last : integer; begin i := hashfunction( key ) ; inc := increment( key ) ; last := (i+(n-1)*inc) mod m; while (i<>last) and (not empty(r[i])) and (r[i].k<>key) do i := (i+inc) mod m; if r[i].k=key then search := i {*** found(r[i]) ***} else search := -1; {*** notfound(key) ***} end;

C source (335.srch.c) Pascal source (335.srch.p)



© Addison-Wesley Publishing Co. Inc.