aboutsummaryrefslogtreecommitdiff
path: root/src/lib/UFind.rs
diff options
context:
space:
mode:
authorMarijn Haverbeke <[email protected]>2011-05-12 17:24:54 +0200
committerMarijn Haverbeke <[email protected]>2011-05-12 21:30:44 +0200
commit3816e57fd2a8ab19e4ac6d4b3ddd5b49d5973ff2 (patch)
tree508982ed2f789aedd89eebd529343d9dc88b8e01 /src/lib/UFind.rs
parentTransitional change to make extfmt output lowercase module name (diff)
downloadrust-3816e57fd2a8ab19e4ac6d4b3ddd5b49d5973ff2.tar.xz
rust-3816e57fd2a8ab19e4ac6d4b3ddd5b49d5973ff2.zip
Downcase std modules again, move to :: for module dereferencing
This should be a snapshot transition.
Diffstat (limited to 'src/lib/UFind.rs')
-rw-r--r--src/lib/UFind.rs37
1 files changed, 0 insertions, 37 deletions
diff --git a/src/lib/UFind.rs b/src/lib/UFind.rs
deleted file mode 100644
index 0bb06d7c..00000000
--- a/src/lib/UFind.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-import Option.none;
-import Option.some;
-
-// A very naive implementation of union-find with unsigned integer nodes.
-
-type node = Option.t[uint];
-type ufind = rec(mutable vec[mutable node] nodes);
-
-fn make() -> ufind {
- let vec[mutable node] v = vec(mutable none[uint]);
- Vec.pop(v); // FIXME: botch
- ret rec(mutable nodes=v);
-}
-
-fn make_set(&ufind ufnd) -> uint {
- auto idx = Vec.len(ufnd.nodes);
- ufnd.nodes += vec(mutable none[uint]);
- ret idx;
-}
-
-fn find(&ufind ufnd, uint n) -> uint {
- alt (ufnd.nodes.(n)) {
- case (none[uint]) { ret n; }
- case (some[uint](?m)) {
- // TODO: "be"
- ret find(ufnd, m);
- }
- }
-}
-
-fn union(&ufind ufnd, uint m, uint n) {
- auto m_root = find(ufnd, m);
- auto n_root = find(ufnd, n);
- auto ptr = some[uint](n_root);
- ufnd.nodes.(m_root) = ptr;
-}
-