summaryrefslogtreecommitdiff
path: root/Source/Graph
diff options
context:
space:
mode:
authorGravatar mikebarnett <unknown>2011-03-10 22:38:47 +0000
committerGravatar mikebarnett <unknown>2011-03-10 22:38:47 +0000
commit3e33bdafb4d882a435f948defaf2c337e06d5191 (patch)
tree8f0484f1ef7e75c36fcee6cc9c6fe9da7ddafd7f /Source/Graph
parent768ee8abb31d912cfdc8eeaf41d7f44f1691ce0c (diff)
Replaced all dictionaries that mapped to bool (i.e., were being used to implement a set) with HashSet. Added a new NonNull method to the cce class that checks to make sure a set is non-null and does not contain null.
Diffstat (limited to 'Source/Graph')
-rw-r--r--Source/Graph/Graph.cs8
1 files changed, 4 insertions, 4 deletions
diff --git a/Source/Graph/Graph.cs b/Source/Graph/Graph.cs
index 8c01d8db..9ad1ce22 100644
--- a/Source/Graph/Graph.cs
+++ b/Source/Graph/Graph.cs
@@ -184,7 +184,7 @@ namespace Graphing {
int n = this.graph.Nodes.Count;
this.postOrderNumberToNode = new Maybe<Node>[n + 1];
this.nodeToPostOrderNumber = new Dictionary<Node, int>();
- Dictionary<Node, bool> visited = new Dictionary<Node, bool>(n);
+ HashSet<Node> visited = new HashSet<Node>();
int currentNumber = 1;
Contract.Assume(this.source != null);
this.PostOrderVisit(this.source, visited, ref currentNumber);
@@ -262,11 +262,11 @@ namespace Graphing {
}
return finger1;
}
- private void PostOrderVisit(Node/*!*/ n, Dictionary<Node, bool> visited, ref int currentNumber) {
+ private void PostOrderVisit(Node/*!*/ n, HashSet<Node> visited, ref int currentNumber) {
Contract.Requires(n != null);
- if (visited.ContainsKey(n))
+ if (visited.Contains(n))
return;
- visited[n] = true;
+ visited.Add(n);
foreach (Node/*!*/ child in this.graph.Successors(n)) {
Contract.Assert(child != null);
PostOrderVisit(child, visited, ref currentNumber);