X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=Robust%2Fsrc%2FUtil%2FLattice.java;h=16c8936940414b957c8a51d44ccd690e5e5f6e1a;hb=86e56822082c7f2a5b4cf512bab901d3ea17ffa7;hp=bc024cfad9cd95f58d7b06bea451823bb879915b;hpb=031636263ce6e4b6f35f3d9162460eb0ef536c2a;p=IRC.git diff --git a/Robust/src/Util/Lattice.java b/Robust/src/Util/Lattice.java index bc024cfa..16c89369 100644 --- a/Robust/src/Util/Lattice.java +++ b/Robust/src/Util/Lattice.java @@ -3,6 +3,7 @@ package Util; import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; +import java.util.Map; import java.util.Set; public class Lattice { @@ -19,6 +20,7 @@ public class Lattice { this.bottom = bottom; table.put(top, new HashSet()); + table.put(bottom, new HashSet()); } @@ -34,6 +36,10 @@ public class Lattice { return table.keySet(); } + public Map> getTable() { + return table; + } + public boolean put(T key) { if (table.containsKey(key)) { return false; @@ -66,7 +72,7 @@ public class Lattice { size++; s.add(value); - if (!table.containsKey(value)) { + if ((!table.containsKey(value)) && (!value.equals(bottom))) { Set lowerNeighbor = new HashSet(); lowerNeighbor.add(bottom); table.put(value, lowerNeighbor); @@ -150,6 +156,13 @@ public class Lattice { public boolean isGreaterThan(T a, T b) { + Set visited = new HashSet(); + return isGreaterThan(a, b, visited); + + } + + public boolean isGreaterThan(T a, T b, Set visited) { + if (a.equals(b)) { return false; } @@ -180,7 +193,10 @@ public class Lattice { boolean reachable = false; for (Iterator iterator = neighborSet.iterator(); iterator.hasNext();) { T neighbor = iterator.next(); - reachable = reachable || isGreaterThan(neighbor, b); + if (!visited.contains(neighbor)) { + visited.add(neighbor); + reachable = reachable || isGreaterThan(neighbor, b, visited); + } } return reachable; }