| 1 | (************************************************************************) |
| 2 | (* * The Rocq Prover / The Rocq Development Team *) |
| 3 | (* v * Copyright INRIA, CNRS and contributors *) |
| 4 | (* <O___,, * (see version control and CREDITS file for authors & dates) *) |
| 5 | (* \VV/ **************************************************************) |
| 6 | (* // * This file is distributed under the terms of the *) |
| 7 | (* * GNU Lesser General Public License Version 2.1 *) |
| 8 | (* * (see LICENSE file for the text of the license) *) |
| 9 | (************************************************************************) |
| 10 | |
| 11 | (** Adapted from Damien Doligez, projet Para, INRIA Rocquencourt, |
| 12 | OCaml stdlib. *) |
| 13 | |
| 14 | (** The following functor is a specialized version of [Weak.Make]. |
| 15 | Here, the responsibility of computing the hash function is now |
| 16 | given to the caller, which makes possible the interleaving of the |
| 17 | hash key computation and the hash-consing. *) |
| 18 | |
| 19 | module type EqType = sig |
| 20 | type t |
| 21 | val eq : t -> t -> bool |
| 22 | end |
| 23 | |
| 24 | type statistics = { |
| 25 | num_bindings: int; |
| 26 | num_buckets: int; |
| 27 | max_bucket_length: int; |
| 28 | bucket_histogram: int array |
| 29 | } |
| 30 | |
| 31 | module type S = sig |
| 32 | type elt |
| 33 | (** Type of hashsets elements. *) |
| 34 | |
| 35 | type t |
| 36 | (** Type of hashsets. *) |
| 37 | |
| 38 | val create : int -> t |
| 39 | (** [create n] creates a fresh hashset with initial size [n]. *) |
| 40 | |
| 41 | val clear : t -> unit |
| 42 | (** Clear the contents of a hashset. *) |
| 43 | |
| 44 | val repr : int -> elt -> t -> elt |
| 45 | (** [repr key constr set] uses [key] to look for [constr] |
| 46 | in the hashet [set]. If [constr] is in [set], returns the |
| 47 | specific representation that is stored in [set]. Otherwise, |
| 48 | [constr] is stored in [set] and will be used as the canonical |
| 49 | representation of this value in the future. *) |
| 50 | |
| 51 | val stats : t -> statistics |
| 52 | (** Recover statistics on the table. *) |
| 53 | end |
| 54 | |
| 55 | module Make (E : EqType) : S with type elt = E.t |
| 56 | |
| 57 | module Combine : sig |
| 58 | val combine : int -> int -> int |
| 59 | val combinesmall : int -> int -> int |
| 60 | val combine3 : int -> int -> int -> int |
| 61 | val combine4 : int -> int -> int -> int -> int |
| 62 | val combine5 : int -> int -> int -> int -> int -> int |
| 63 | end |