package frenetic
The Frenetic Programming Language and Runtime System
Install
Dune Dependency
Authors
Maintainers
Sources
5.0.5.tar.gz
md5=baf754df13a759c32f2c86a1b6f328da
sha512=80140900e7009ccab14b25e244fe7edab87d858676f8a4b3799b4fea16825013cf68363fe5faec71dd54ba825bb4ea2f812c2c666390948ab217ffa75d9cbd29
doc/src/frenetic.kernel/Hashcons.ml.html
Source file Hashcons.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
open Core module type HASHTYPE = sig type t val get : t -> int val unget : int -> t val clear : Int.Set.t -> unit end module Make (Value : Hashtbl.Key) : HASHTYPE with type t = Value.t = struct module T = Hashtbl.Make (Value) (* TODO(arjun): Since these are allocated contiguously, it would be better to use a growable array ArrayList<Int> *) (* TODO(jnf): are you suggesting we port Frentic to Java?! *) module U = Int.Table type t = Value.t let tbl : int T.t = T.create ~size:1000 () let untbl : t U.t = U.create ~size:1000 () let idx = ref 0 let clear (preserve : Int.Set.t) : unit = begin (* SJS: iterate over _copy_ of tbl to avoid side effect hell! *) T.to_alist tbl |> List.filter ~f:(fun (_,v) -> not (Set.mem preserve v)) |> List.iter ~f:(fun (k,v) -> T.remove tbl k; U.remove untbl v); idx := 1 + T.fold tbl ~init:0 ~f:(fun ~key ~data -> max data) end let gensym () = let r = !idx in idx := !idx + 1; r let get (v : t) = T.find_or_add tbl v ~default:(fun () -> let n = gensym () in U.add_exn untbl n v; n) let unget (idx : int) : t = U.find_exn untbl idx end
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>