mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
add containers_misc.Puf.iter
This commit is contained in:
parent
e3b4c5eaf9
commit
ff956b9cc2
2 changed files with 18 additions and 1 deletions
|
|
@ -58,6 +58,8 @@ module PArray = struct
|
||||||
a
|
a
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let iteri f t = Array.iteri f (reroot t)
|
||||||
|
|
||||||
let get t i =
|
let get t i =
|
||||||
match !t with
|
match !t with
|
||||||
| Array a -> a.(i)
|
| Array a -> a.(i)
|
||||||
|
|
@ -204,6 +206,9 @@ module type S = sig
|
||||||
(** [iter_equiv_class uf a f] calls [f] on every element of [uf] that
|
(** [iter_equiv_class uf a f] calls [f] on every element of [uf] that
|
||||||
is congruent to [a], including [a] itself. *)
|
is congruent to [a], including [a] itself. *)
|
||||||
|
|
||||||
|
val iter : _ t -> (elt -> unit) -> unit
|
||||||
|
(** Iterate on all root values *)
|
||||||
|
|
||||||
val inconsistent : _ t -> (elt * elt * elt * elt) option
|
val inconsistent : _ t -> (elt * elt * elt * elt) option
|
||||||
(** Check whether the UF is inconsistent. It returns [Some (a, b, a', b')]
|
(** Check whether the UF is inconsistent. It returns [Some (a, b, a', b')]
|
||||||
in case of inconsistency, where a = b, a = a' and b = b' by congruence,
|
in case of inconsistency, where a = b, a = a' and b = b' by congruence,
|
||||||
|
|
@ -222,7 +227,8 @@ module type S = sig
|
||||||
|
|
||||||
val explain_distinct : 'e t -> elt -> elt -> elt * elt
|
val explain_distinct : 'e t -> elt -> elt -> elt * elt
|
||||||
(** [explain_distinct uf a b] gives the original pair [a', b'] that
|
(** [explain_distinct uf a b] gives the original pair [a', b'] that
|
||||||
made [a] and [b] distinct by calling [distinct a' b'] *)
|
made [a] and [b] distinct by calling [distinct a' b']. The
|
||||||
|
terms must be distinct, otherwise Failure is raised. *)
|
||||||
end
|
end
|
||||||
|
|
||||||
module IH = Hashtbl.Make(struct type t = int let equal i j = i = j let hash i = i end)
|
module IH = Hashtbl.Make(struct type t = int let equal i j = i = j let hash i = i end)
|
||||||
|
|
@ -446,6 +452,13 @@ module Make(X : ID) : S with type elt = X.t = struct
|
||||||
in
|
in
|
||||||
traverse ia
|
traverse ia
|
||||||
|
|
||||||
|
let iter uf f =
|
||||||
|
PArray.iteri
|
||||||
|
(fun i e -> match e with
|
||||||
|
| None -> ()
|
||||||
|
| Some d -> if d.next = i then f d.elt
|
||||||
|
) uf.data
|
||||||
|
|
||||||
let inconsistent uf = uf.inconsistent
|
let inconsistent uf = uf.inconsistent
|
||||||
|
|
||||||
(** Closest common ancestor of the two elements in the proof forest *)
|
(** Closest common ancestor of the two elements in the proof forest *)
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,10 @@ module type S = sig
|
||||||
(** [iter_equiv_class uf a f] calls [f] on every element of [uf] that
|
(** [iter_equiv_class uf a f] calls [f] on every element of [uf] that
|
||||||
is congruent to [a], including [a] itself. *)
|
is congruent to [a], including [a] itself. *)
|
||||||
|
|
||||||
|
val iter : _ t -> (elt -> unit) -> unit
|
||||||
|
(** Iterate on all root values
|
||||||
|
@since NExT_RELEASE *)
|
||||||
|
|
||||||
val inconsistent : _ t -> (elt * elt * elt * elt) option
|
val inconsistent : _ t -> (elt * elt * elt * elt) option
|
||||||
(** Check whether the UF is inconsistent. It returns [Some (a, b, a', b')]
|
(** Check whether the UF is inconsistent. It returns [Some (a, b, a', b')]
|
||||||
in case of inconsistency, where a = b, a = a' and b = b' by congruence,
|
in case of inconsistency, where a = b, a = a' and b = b' by congruence,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue