]> matita.cs.unibo.it Git - helm.git/commitdiff
added iterators over registry contents (fold, iter, to_list)
authorStefano Zacchiroli <zack@upsilon.cc>
Thu, 20 May 2004 09:27:06 +0000 (09:27 +0000)
committerStefano Zacchiroli <zack@upsilon.cc>
Thu, 20 May 2004 09:27:06 +0000 (09:27 +0000)
helm/ocaml/registry/helm_registry.ml
helm/ocaml/registry/helm_registry.mli

index 0c7b437238d1e57c23a9d5bcf73d83d6e4fde2b1..2b6461b5620bc0a0f4b35090f601eb3c40b26643 100644 (file)
@@ -310,6 +310,10 @@ let load_from ?path fname =
   end else
     load_from_absolute fname
 
+let fold f init = Hashtbl.fold (fun k v acc -> f acc k v) registry init
+let iter f = fold (fun _ k v -> f k v) ()
+let to_list () = fold (fun acc k v -> (k, v) :: acc) []
+
   (* DEBUGGING ONLY *)
 
 let dump () = Hashtbl.iter (fun k v -> printf "%s = %s\n" k v) registry
index 1f40b5453fa0e352b859e352b41b4b9426d53c23..62e85c5f1aaf65d9590866d2289ff03eb000baae 100644 (file)
@@ -108,6 +108,10 @@ val set: key:string -> value:string -> unit
    * raise Key_not_found until the key will be redefined *)
 val unset: string -> unit
 
+val fold: ('a -> string -> string -> 'a) -> 'a -> 'a
+val iter: (string -> string -> unit) -> unit
+val to_list: unit -> (string * string) list
+
 (** {2 Typed interface}
  * Three basic types are supported: strings, int and strings list. Strings
  * correspond literally to what is written inside double quotes; int to the