From 4de8e995bb4550b3da94aa15a9d71ddc44dad0a8 Mon Sep 17 00:00:00 2001 From: Claudio Sacerdoti Coen Date: Thu, 17 May 2012 11:32:52 +0000 Subject: [PATCH] hash function exported --- matita/components/ng_kernel/nReference.ml | 4 ++++ matita/components/ng_kernel/nReference.mli | 1 + matita/components/ng_kernel/nUri.ml | 3 ++- matita/components/ng_kernel/nUri.mli | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/matita/components/ng_kernel/nReference.ml b/matita/components/ng_kernel/nReference.ml index e209d05be..bb560bfd6 100644 --- a/matita/components/ng_kernel/nReference.ml +++ b/matita/components/ng_kernel/nReference.ml @@ -30,6 +30,10 @@ let compare (Ref (u1,s1)) (Ref (u2,s2)) = if res = 0 then compare s1 s2 else res ;; +let hash (Ref (uri,spec)) = + Hashtbl.hash spec + NUri.hash uri +;; + module OrderedStrings = struct type t = string diff --git a/matita/components/ng_kernel/nReference.mli b/matita/components/ng_kernel/nReference.mli index d7f87e57c..4c3dd3416 100644 --- a/matita/components/ng_kernel/nReference.mli +++ b/matita/components/ng_kernel/nReference.mli @@ -27,6 +27,7 @@ val reference_of_spec: NUri.uri -> spec -> reference val eq: reference -> reference -> bool val compare: reference -> reference -> int +val hash: reference -> int val string_of_reference: reference -> string val reference_of_string: string -> reference diff --git a/matita/components/ng_kernel/nUri.ml b/matita/components/ng_kernel/nUri.ml index e92be39e1..b3c877768 100644 --- a/matita/components/ng_kernel/nUri.ml +++ b/matita/components/ng_kernel/nUri.ml @@ -48,12 +48,13 @@ fun s -> let eq = (==);; let compare (n1,_) (n2,_) = n2 - n1;; +let hash (n,_) = n;; module HT = struct type t = uri let equal = eq let compare = compare - let hash (n,_) = n;; + let hash = hash;; end;; module UriHash = Hashtbl.Make(HT);; diff --git a/matita/components/ng_kernel/nUri.mli b/matita/components/ng_kernel/nUri.mli index a133c04c8..25d319eb4 100644 --- a/matita/components/ng_kernel/nUri.mli +++ b/matita/components/ng_kernel/nUri.mli @@ -19,6 +19,7 @@ val baseuri_of_uri: uri -> string val uri_of_string: string -> uri val eq: uri -> uri -> bool val compare: uri -> uri -> int +val hash: uri -> int module UriHash: Hashtbl.S with type key = uri module UriMap: Map.S with type key = uri -- 2.39.2