Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 4d612ef2cc
Fetching contributors…

Cannot retrieve contributors at this time

49 lines (43 sloc) 1.637 kb
Copyright © 2011 MLstate
This file is part of OPA.
OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.
OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.
You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <>.
(* CF mi *)
type ('a, 'b) t = ('a, ('b, unit) Hashtbl.t) Hashtbl.t
let create = Hashtbl.create
let clear = Hashtbl.clear
let copy = Hashtbl.copy
let remove = Hashtbl.remove
let mem = Hashtbl.mem
let iter = Hashtbl.iter
let fold = Hashtbl.fold
let length = Hashtbl.length
let add t k v =
let all = try Hashtbl.find t k with | Not_found -> Hashtbl.create 10 in
Hashtbl.replace all v (); Hashtbl.replace t k all
let find t k = try Hashtbl.find t k with | Not_found -> Hashtbl.create 10
let mem_cp t (k, v) = Hashtbl.mem (find t k) v
let gen_to_list f t =
let fold k v acc = (f k v)::acc in
Hashtbl.fold fold t []
let to_list t = gen_to_list (fun a b -> a, gen_to_list (fun a _ -> a) b) t
let find_list t k =
gen_to_list (fun a _ -> a) (Hashtbl.find t k)
| Not_found -> []
let iter_list f =
let iter k v = f k (gen_to_list (fun a _ -> a) v) in
Hashtbl.iter iter
let fold_list f =
let fold k v ac = f k (gen_to_list (fun a _ -> a) v) ac in
Hashtbl.fold fold
Jump to Line
Something went wrong with that request. Please try again.