diff --git a/src/libstd/std.rc b/src/libstd/std.rc index d1b578f3d87..40a03ae25c2 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -15,7 +15,7 @@ import core::*; export net, uv; export c_vec, util, timer; -export bitv, deque, fun_treemap, list, map, smallintmap, sort, treemap, ufind; +export bitv, deque, fun_treemap, list, map, smallintmap, sort, treemap; export rope, arena; export ebml, dbg, getopts, json, rand, sha1, term, time, prettyprint; export test, tempfile, serialization; @@ -49,8 +49,6 @@ mod rope; mod smallintmap; mod sort; mod treemap; -mod ufind; - // And ... other stuff diff --git a/src/libstd/ufind.rs b/src/libstd/ufind.rs deleted file mode 100644 index 9a7483553dc..00000000000 --- a/src/libstd/ufind.rs +++ /dev/null @@ -1,52 +0,0 @@ - -import core::option; -import option::{some, none}; - - -// A very naive implementation of union-find with unsigned integer nodes. -// Maintains the invariant that the root of a node is always equal to or less -// than the node itself. -type node = option; - -type ufind = {mut nodes: [mut node]}; - -fn make() -> ufind { ret {mut nodes: [mut]}; } - -fn make_set(ufnd: ufind) -> uint { - let idx = vec::len(ufnd.nodes); - ufnd.nodes += [mut none::]; - ret idx; -} - - -/// Creates sets as necessary to ensure that least `n` sets are present in the -/// data structure. -fn grow(ufnd: ufind, n: uint) { - while set_count(ufnd) < n { make_set(ufnd); } -} - -fn find(ufnd: ufind, n: uint) -> uint { - alt ufnd.nodes[n] { - none { ret n; } - some(m) { let m_ = m; ret find(ufnd, m_); } - } -} - -fn union(ufnd: ufind, m: uint, n: uint) { - let m_root = find(ufnd, m); - let n_root = find(ufnd, n); - if m_root < n_root { - ufnd.nodes[n_root] = some::(m_root); - } else if m_root > n_root { ufnd.nodes[m_root] = some::(n_root); } -} - -fn set_count(ufnd: ufind) -> uint { ret vec::len::(ufnd.nodes); } - - -// Removes all sets with IDs greater than or equal to the given value. -fn prune(ufnd: ufind, n: uint) { - // TODO: Use "slice" once we get rid of "const" - - let mut len = vec::len::(ufnd.nodes); - while len != n { vec::pop::(ufnd.nodes); len -= 1u; } -} diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index 3b8fe334dc4..4869c419573 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -1,4 +1,4 @@ -import std::{ufind, map, smallintmap}; +import std::{map, smallintmap}; import result::result; import std::map::hashmap; import driver::session; diff --git a/src/rustc/middle/typeck.rs b/src/rustc/middle/typeck.rs index a1b16471b1d..279df880ffc 100644 --- a/src/rustc/middle/typeck.rs +++ b/src/rustc/middle/typeck.rs @@ -61,7 +61,6 @@ import std::smallintmap::map; import std::map; import std::map::{hashmap, int_hash}; import std::serialization::{serialize_uint, deserialize_uint}; -import std::ufind; import vec::each; import syntax::print::pprust::*; import util::common::{indent, indenter};