package containers
A modular, clean and powerful extension of the OCaml standard library
Install
Dune Dependency
Authors
Maintainers
Sources
v2.8.1.tar.gz
md5=d84e09c5d0abc501aa17cd502e31a038
sha512=8b832f4ada6035e80d81be0cfb7bdffb695ec67d465ed6097a144019e2b8a8f909095e78019c3da2d8181cc3cd730cd48f7519e87d3162442562103b7f36aabb
doc/src/containers.data/CCMixset.ml.html
Source file CCMixset.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 48 49 50 51 52 53 54 55 56
(* This file is free software, part of containers. See file "license" for more details. *) (** {1 Set of Heterogeneous Values} *) module IMap = Map.Make(struct type t = int let compare : int -> int -> int = compare end) (*$R let k1 : int key = newkey () in let k2 : int key = newkey () in let k3 : string key = newkey () in let set = empty |> set ~key:k1 1 |> set ~key:k2 2 |> set ~key:k3 "3" in assert (get ~key:k1 set = Some 1); assert (get ~key:k2 set = Some 2); assert (get ~key:k3 set = Some "3"); () *) type t = (unit -> unit) IMap.t and 'a key = { id: int; mutable opt : 'a option; };; let newkey_n_ = ref 0 let newkey () = let id = !newkey_n_ in incr newkey_n_; { id; opt=None; } let empty = IMap.empty let get ~key set = key.opt <- None; try (IMap.find key.id set) (); key.opt with Not_found -> None let get_exn ~key set = match get ~key set with | None -> raise Not_found | Some v -> v let set ~key v set = IMap.add key.id (fun () -> key.opt <- Some v) set let cardinal set = IMap.cardinal set
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>