Explorar el Código

Continuing HashSet-ectomy

Caleb Fangmeier hace 6 años
padre
commit
ec0355b43c
Se han modificado 1 ficheros con 11 adiciones y 2 borrados
  1. 11 2
      src/com/pact/Node.java

+ 11 - 2
src/com/pact/Node.java

@@ -272,8 +272,8 @@ public class Node {
     }
 
     private Node reduce() {
-        HashSet<Node> uniqueC = new HashSet<>();
-        HashSet<Node> dupC = new HashSet<>();
+        List<Node> uniqueC = new ArrayList<>();
+        List<Node> dupC = new ArrayList<>();
         for (Node child : this.children) {
             if (child.inSet(uniqueC))
                 dupC.add(child);
@@ -299,6 +299,15 @@ public class Node {
         return new Node(null, result);
     }
 
+    private boolean inSet(List<Node> h) {
+        for (Node curr : h) {
+            if (curr.equals(this)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     private boolean inSet(HashSet<Node> h) {
         for (Node curr : h) {
             if (curr.equals(this)) {