(********************************************************************)
(*  OCaml code from the book ``Learn Programming with OCaml''       *)
(*  See https://usr.lmf.cnrs.fr/lpo/                                *)
(*                                                                  *)
(*  Sylvain Conchon and Jean-Christophe Filliâtre                   *)
(*  Copyright 2025 Université Paris-Saclay and CNRS                 *)
(*                                                                  *)
(*  Openly licensed via CC BY SA 4.0                                *)
(*  See https://creativecommons.org/licenses/by-sa/4.0/deed.en      *)
(********************************************************************)

(* Program 45 on page 236
   Resizing a Hash Table *)

  let resize h =
    let n = Array.length h.buckets in
    let m = 2 * n in
    let a = Array.make m [] in
    let rehash x =
      let i = (X.hash x land max_int) mod m in
      a.(i) <- x :: a.(i)
    in
    Array.iter (List.iter rehash) h.buckets;
    h.buckets <- a

This document was generated using caml2html