PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/visualiser/counter.ml

http://github.com/hhughes/ocaml-frui
OCaml | 12 lines | 12 code | 0 blank | 0 comment | 0 complexity | 33d014d97b9d0c62a75ffabe38b15343 MD5 | raw file
 1class counter =
 2object (self)
 3  val counters = Hashtbl.create 10
 4  method add (name : string) = Hashtbl.add counters name (new Fvar.fvar 0)
 5  method get name = (Hashtbl.find counters name)#get
 6  method set name v = (Hashtbl.find counters name)#set v 
 7  method inc name = let v = self#get name in (*Logger.debug (Printf.sprintf "inc to %d" (v+1));*) self#set name (v+1)
 8  method behavior name = (Hashtbl.find counters name)#b
 9  method kvps = Hashtbl.fold (fun k v a -> (k,v#get) :: a) counters []
10  method values = let kvps = self#kvps in snd (List.split kvps)
11  method mem = Hashtbl.mem counters
12end