Fix Hashtbl.MakeSeeded.{add,replace,of}_seq

Hashtbl.MakeSeeded.{add,replace}_seq were not using the hash function
provided by the functor (Hashtbl.MakeSeeded.of_seq uses replace_seq and
so also has to be redefined locally).
master
David Allsopp 2018-12-17 12:27:37 +01:00 committed by Xavier Leroy
parent 2dc4c0dcb1
commit fc8be501aa
2 changed files with 15 additions and 3 deletions

View File

@ -355,6 +355,10 @@ OCaml 4.08.0
- #1525: Make function set_max_indent respect documentation
(Pierre Weis, Richard Bonichon, review by Florian Angeletti)
- GPR#2202: Correct Hashtbl.MakeSeeded.{add_seq,replace_seq,of_seq} to use
functor hash function instead of default hash function.
(David Allsopp, review by Alain Frisch)
### Other libraries:
- #2222: Set default status in waitpid when pid is zero. Otherwise,

View File

@ -570,6 +570,17 @@ module MakeSeeded(H: SeededHashedType): (SeededS with type key = H.t) =
H.equal k key || mem_in_bucket next in
mem_in_bucket h.data.(key_index h key)
let add_seq tbl i =
Seq.iter (fun (k,v) -> add tbl k v) i
let replace_seq tbl i =
Seq.iter (fun (k,v) -> replace tbl k v) i
let of_seq i =
let tbl = create 16 in
replace_seq tbl i;
tbl
let iter = iter
let filter_map_inplace = filter_map_inplace
let fold = fold
@ -578,9 +589,6 @@ module MakeSeeded(H: SeededHashedType): (SeededS with type key = H.t) =
let to_seq = to_seq
let to_seq_keys = to_seq_keys
let to_seq_values = to_seq_values
let add_seq = add_seq
let replace_seq = replace_seq
let of_seq = of_seq
end
module Make(H: HashedType): (S with type key = H.t) =