diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2015-08-18 17:41:46 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2015-08-18 17:41:46 -0400 |
| commit | dcf6f08138e7831d75b39e4c11c0a5acc2cd3831 (patch) | |
| tree | 4affeedfdb855f089d812d3f4f5823984e3b17a9 | |
| parent | 4b1d3b703629db036ce685a852b80bf196419bb5 (diff) | |
| download | rust-dcf6f08138e7831d75b39e4c11c0a5acc2cd3831.tar.gz rust-dcf6f08138e7831d75b39e4c11c0a5acc2cd3831.zip | |
kill the old funky `can_reach` fn
| -rw-r--r-- | src/librustc/util/common.rs | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 2314368177c..1ad5ae9917d 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -203,49 +203,6 @@ pub fn block_query<P>(b: &ast::Block, p: P) -> bool where P: FnMut(&ast::Expr) - return v.flag; } -/// K: Eq + Hash<S>, V, S, H: Hasher<S> -/// -/// Determines whether there exists a path from `source` to `destination`. The -/// graph is defined by the `edges_map`, which maps from a node `S` to a list of -/// its adjacent nodes `T`. -/// -/// Efficiency note: This is implemented in an inefficient way because it is -/// typically invoked on very small graphs. If the graphs become larger, a more -/// efficient graph representation and algorithm would probably be advised. -pub fn can_reach<T, S>(edges_map: &HashMap<T, Vec<T>, S>, source: T, - destination: T) -> bool - where S: HashState, T: Hash + Eq + Clone, -{ - if source == destination { - return true; - } - - // Do a little breadth-first-search here. The `queue` list - // doubles as a way to detect if we've seen a particular FR - // before. Note that we expect this graph to be an *extremely - // shallow* tree. - let mut queue = vec!(source); - let mut i = 0; - while i < queue.len() { - match edges_map.get(&queue[i]) { - Some(edges) => { - for target in edges { - if *target == destination { - return true; - } - - if !queue.iter().any(|x| x == target) { - queue.push((*target).clone()); - } - } - } - None => {} - } - i += 1; - } - return false; -} - /// Memoizes a one-argument closure using the given RefCell containing /// a type implementing MutableMap to serve as a cache. /// |
