summaryrefslogtreecommitdiff
path: root/src/union_find_fn.sml
diff options
context:
space:
mode:
authorGravatar Ziv Scully <ziv@mit.edu>2015-11-05 01:48:42 -0500
committerGravatar Ziv Scully <ziv@mit.edu>2015-11-05 01:48:42 -0500
commitb2c1c524f9074637cfbedc07a065f2c75d635e73 (patch)
tree1dfe8b6da43796d2d98039198de2dadf5f8f4e09 /src/union_find_fn.sml
parent2e9eb1c2b1b1279e627034b6bfbfb86e4f2bfba7 (diff)
First draft of more specific formulas for queries.
Diffstat (limited to 'src/union_find_fn.sml')
-rw-r--r--src/union_find_fn.sml5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/union_find_fn.sml b/src/union_find_fn.sml
index e6f8d9bf..7880591f 100644
--- a/src/union_find_fn.sml
+++ b/src/union_find_fn.sml
@@ -3,6 +3,7 @@ functor UnionFindFn(K : ORD_KEY) :> sig
val empty : unionFind
val union : unionFind * K.ord_key * K.ord_key -> unionFind
val union' : (K.ord_key * K.ord_key) * unionFind -> unionFind
+ val together : unionFind * K.ord_key * K.ord_key -> bool
val classes : unionFind -> K.ord_key list list
end = struct
@@ -34,6 +35,10 @@ fun find ((uf, _), x) = (S.listItems o #1 o findPair) (uf, x)
fun classes (_, cs) = (map S.listItems o M.listItems) cs
+fun together ((uf, _), x, y) = case K.compare (#2 (findPair (uf, x)), #2 (findPair (uf, y))) of
+ EQUAL => true
+ | _ => false
+
fun union ((uf, cs), x, y) =
let
val (xSet, xRep) = findPair (uf, x)