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 vcreates a new reference with contentsv. val equal: 'a uref * 'a uref -> bool-
equal (ur1, ur2)returnstrueif, and only if,ur1andur2were created by the same call touRefor if they have been unioned by alink,union, orunifyoperation. val !! : 'a uref -> 'a-
!! urreturns the contents ofur. val update : 'a uref * 'a -> unit-
update (ur, v)updates the contents ofurto bev.
val unify : ('a * 'a -> 'a) -> 'a uref * 'a uref -> bool-
unify f (ur1, ur2)unionsur1andur2(i.e., after this call, the expressionequal(r1, ur2)will returntrue) and returnstrueif 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)unionsur1andur2(i.e., after this call, the expressionequal(r1, ur2)will returntrue) and returnstrueif they were not equal prior to the call tounion. The contents of the unioned reference is set to one ofv1orv2, wherev1(resp.v2) was the contents ofur1(resp.ur2) prior to the call tounion.
val link : 'a uref * 'a uref -> bool-
link (ur1, ur2)unionsur1andur2(i.e., after this call, the expressionequal(r1, ur2)will returntrue) and returnstrueif they were not equal prior to the call tolink. The contents of the unioned reference is set tov1, wherev1was the contents ofur1prior to the call tolink.