1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
let rec find_rec key = function
Empty ->
raise Not_found
| Cons(k, d, rest) ->
if compare key k = 0 then d else find_rec key rest
let find h key =
match h.data.((hash key) mod (Array.length h.data)) with
Empty -> raise Not_found
| Cons(k1, d1, rest1) ->
if compare key k1 = 0 then d1 else
match rest1 with
Empty -> raise Not_found
| Cons(k2, d2, rest2) ->
if compare key k2 = 0 then d2 else
match rest2 with
Empty -> raise Not_found
| Cons(k3, d3, rest3) ->
if compare key k3 = 0 then d3 else find_rec key rest3 |
Partager