diff --git a/src/data/CCHashconsedSet.ml b/src/data/CCHashconsedSet.ml index b4e9e15e..7f9a2985 100644 --- a/src/data/CCHashconsedSet.ml +++ b/src/data/CCHashconsedSet.ml @@ -60,6 +60,9 @@ module type S = sig val compare : t -> t -> int (** Fast (arbitrary) comparisontest [O(1)] *) + val hash : t -> int + (** Fast (arbitrary, deterministic) hash [O(1)] *) + val add : elt -> t -> t val remove : elt -> t -> t @@ -207,6 +210,8 @@ module Make(E : ELT) : S with type elt = E.t = struct let compare t1 t2 = Pervasives.compare t1.id t2.id + let hash t = t.id land max_int + let mem x t = mem_rec_ (E.hash x) x t let mk_node_ prefix switch l r = match l.cell, r.cell with diff --git a/src/data/CCHashconsedSet.mli b/src/data/CCHashconsedSet.mli index 2cc30ca4..a856d445 100644 --- a/src/data/CCHashconsedSet.mli +++ b/src/data/CCHashconsedSet.mli @@ -62,6 +62,9 @@ module type S = sig val compare : t -> t -> int (** Fast (arbitrary) comparisontest [O(1)] *) + val hash : t -> int + (** Fast (arbitrary, deterministic) hash [O(1)] *) + val add : elt -> t -> t val remove : elt -> t -> t