From 3e33bdafb4d882a435f948defaf2c337e06d5191 Mon Sep 17 00:00:00 2001 From: mikebarnett Date: Thu, 10 Mar 2011 22:38:47 +0000 Subject: 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. --- Source/Graph/Graph.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Source/Graph') 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[n + 1]; this.nodeToPostOrderNumber = new Dictionary(); - Dictionary visited = new Dictionary(n); + HashSet visited = new HashSet(); 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 visited, ref int currentNumber) { + private void PostOrderVisit(Node/*!*/ n, HashSet 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); -- cgit v1.2.3