fixed bug in FlatHashtbl.remove

This commit is contained in:
Simon Cruanes 2013-03-07 10:12:47 +01:00
parent 88ceeb5430
commit c192d5558a
2 changed files with 3 additions and 4 deletions

View file

@ -182,7 +182,7 @@ module Make(H : Hashtbl.HashedType) =
let j = addr h n i in let j = addr h n i in
match buckets.(j) with match buckets.(j) with
| Used (key', _) when H.equal key key' -> | Used (key', _) when H.equal key key' ->
buckets.(i) <- Deleted; buckets.(j) <- Deleted;
t.size <- t.size - 1 (* remove slot *) t.size <- t.size - 1 (* remove slot *)
| Deleted | Used _ -> | Deleted | Used _ ->
probe h n (i+1) (* search further *) probe h n (i+1) (* search further *)

View file

@ -47,9 +47,8 @@ let test_eq () =
let h = IHashtbl.create 3 in let h = IHashtbl.create 3 in
IHashtbl.replace h 1 "odd"; IHashtbl.replace h 1 "odd";
IHashtbl.replace h 2 "even"; IHashtbl.replace h 2 "even";
OUnit.assert_equal (IHashtbl.find h 3) "odd"; OUnit.assert_equal (IHashtbl.find h 1) "odd";
OUnit.assert_equal (IHashtbl.find h 51) "odd"; OUnit.assert_equal (IHashtbl.find h 2) "even";
OUnit.assert_equal (IHashtbl.find h 42) "even";
() ()
let test_copy () = let test_copy () =