Skip to content

Commit

Permalink
remove Graph::sort as it is unused
Browse files Browse the repository at this point in the history
  • Loading branch information
Eh2406 committed Oct 5, 2018
1 parent ae4a2fa commit a26676a
Showing 1 changed file with 0 additions and 31 deletions.
31 changes: 0 additions & 31 deletions src/cargo/util/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ pub struct Graph<N, E> {
nodes: HashMap<N, HashMap<N, E>>,
}

enum Mark {
InProgress,
Done,
}

pub type Nodes<'a, N, E> = Keys<'a, N, HashMap<N, E>>;
pub type Edges<'a, N, E> = Iter<'a, N, E>;

Expand Down Expand Up @@ -41,32 +36,6 @@ impl<N: Eq + Hash + Clone, E: Default> Graph<N, E> {
self.nodes.get(from).map(|set| set.iter())
}

pub fn sort(&self) -> Option<Vec<N>> {
let mut ret = Vec::new();
let mut marks = HashMap::new();

for node in self.nodes.keys() {
self.visit(node, &mut ret, &mut marks);
}

Some(ret)
}

fn visit(&self, node: &N, dst: &mut Vec<N>, marks: &mut HashMap<N, Mark>) {
if marks.contains_key(node) {
return;
}

marks.insert(node.clone(), Mark::InProgress);

for child in self.nodes[node].keys() {
self.visit(child, dst, marks);
}

dst.push(node.clone());
marks.insert(node.clone(), Mark::Done);
}

pub fn iter(&self) -> Nodes<N, E> {
self.nodes.keys()
}
Expand Down

0 comments on commit a26676a

Please sign in to comment.