add CCHashconsedSet.hash

This commit is contained in:
Simon Cruanes 2015-06-04 21:24:17 +02:00
parent b31c76e18b
commit 4049aa9269
2 changed files with 8 additions and 0 deletions

View file

@ -60,6 +60,9 @@ module type S = sig
val compare : t -> t -> int val compare : t -> t -> int
(** Fast (arbitrary) comparisontest [O(1)] *) (** Fast (arbitrary) comparisontest [O(1)] *)
val hash : t -> int
(** Fast (arbitrary, deterministic) hash [O(1)] *)
val add : elt -> t -> t val add : elt -> t -> t
val remove : 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 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 mem x t = mem_rec_ (E.hash x) x t
let mk_node_ prefix switch l r = match l.cell, r.cell with let mk_node_ prefix switch l r = match l.cell, r.cell with

View file

@ -62,6 +62,9 @@ module type S = sig
val compare : t -> t -> int val compare : t -> t -> int
(** Fast (arbitrary) comparisontest [O(1)] *) (** Fast (arbitrary) comparisontest [O(1)] *)
val hash : t -> int
(** Fast (arbitrary, deterministic) hash [O(1)] *)
val add : elt -> t -> t val add : elt -> t -> t
val remove : elt -> t -> t val remove : elt -> t -> t