mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
add CCHashconsedSet.hash
This commit is contained in:
parent
b31c76e18b
commit
4049aa9269
2 changed files with 8 additions and 0 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue