package union-find-lattice

  1. Overview
  2. Docs
Persistent union-find data-structures with lattice operations (order, meet, join)

Install

dune-project
 Dependency

Authors

Maintainers

Sources

union-find-lattice-0.1.0.tbz
sha256=ecaf1444cd0e9d21174d854da0d2eea56d685180cc1e098016e2c66bc809f8ab
sha512=f12612357504879f78094ffa623bf44ec87c7f7adeeea1809c0b74fdf41e51a88958634d51d3f8bd8881c577a635ef81beaff91d0361195f9a65a5724ce096a9

doc/src/union-find-lattice.utils/functions.ml.html

Source file functions.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
(**************************************************************************)
(*  This file is part of the Codex semantics library                      *)
(*    (Union-find lattice subcomponent).                                  *)
(*                                                                        *)
(*  Copyright (C) 2026                                                    *)
(*    CEA (Commissariat à l'énergie atomique et aux énergies              *)
(*         alternatives)                                                  *)
(*                                                                        *)
(*  you can redistribute it and/or modify it under the terms of the GNU   *)
(*  Lesser General Public License as published by the Free Software       *)
(*  Foundation, version 2.1.                                              *)
(*                                                                        *)
(*  It 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 Lesser General Public License for more details.                   *)
(*                                                                        *)
(*  See the GNU Lesser General Public License version 3.0                 *)
(*  for more details (enclosed in the file LICENSE).                      *)
(*                                                                        *)
(**************************************************************************)

(** Various useful functions *)

let hash_pair x y = y + (x lsl 16) + (x lsl 6) - x

let pp_option o = Format.pp_print_option ~none:(fun fmt () -> Format.pp_print_string fmt "None") o

let range_fold f n init =
  let rec loop j acc = if j > n then acc else loop (j+1) (f j acc) in
  loop 0 init

let list_of_hashtbl_keys table = PersistentArray.IntHashtable.fold (fun k _ l -> k::l) table []