The URef
structure provides mutable references with Union-Find
semantics. The interface is similar to that of references, but
adds operations to union two references together. When two uref
values are joined by one of the union operations, they become
equal (and, thus, their contents will be equal too).
The original design and implementation of this module was by Fritz Henglein.
Synopsis
signature UREF
structure URef : UREF
Interface
type 'a uref
val uRef: 'a -> 'a uref
val equal: 'a uref * 'a uref -> bool
val !! : 'a uref -> 'a
val update : 'a uref * 'a -> unit
val unify : ('a * 'a -> 'a) -> 'a uref * 'a uref -> bool
val union : 'a uref * 'a uref -> bool
val link : 'a uref * 'a uref -> bool
Description
type 'a uref
-
The type constructor for union-find references.
val uRef: 'a -> 'a uref
-
uRef v
creates a new reference with contentsv
. val equal: 'a uref * 'a uref -> bool
-
equal (ur1, ur2)
returnstrue
if, and only if,ur1
andur2
were created by the same call touRef
or if they have been unioned by alink
,union
, orunify
operation. val !! : 'a uref -> 'a
-
!! ur
returns the contents ofur
. val update : 'a uref * 'a -> unit
-
update (ur, v)
updates the contents ofur
to bev
.
val unify : ('a * 'a -> 'a) -> 'a uref * 'a uref -> bool
-
unify f (ur1, ur2)
unionsur1
andur2
(i.e., after this call, the expressionequal(r1, ur2)
will returntrue
) and returnstrue
if they were not equal prior to the call tounify
. The contents of the unioned reference is set tof (v1, v2)
, wherev1
(resp.v2
) was the contents ofur1
(resp.ur2
) prior to the call tounify
.
val union : 'a uref * 'a uref -> bool
-
union (ur1, ur2)
unionsur1
andur2
(i.e., after this call, the expressionequal(r1, ur2)
will returntrue
) and returnstrue
if they were not equal prior to the call tounion
. The contents of the unioned reference is set to one ofv1
orv2
, wherev1
(resp.v2
) was the contents ofur1
(resp.ur2
) prior to the call tounion
.
val link : 'a uref * 'a uref -> bool
-
link (ur1, ur2)
unionsur1
andur2
(i.e., after this call, the expressionequal(r1, ur2)
will returntrue
) and returnstrue
if they were not equal prior to the call tolink
. The contents of the unioned reference is set tov1
, wherev1
was the contents ofur1
prior to the call tolink
.