Ejemplo n.º 1
0
 /** Visit each predecessor of this node applying the given visitor. Breadth first. */
 private <Alpha, Beta> void doVisitPredecessors(
     Visitor<Alpha, Beta> visitor, Alpha arg1, Beta arg2, Set<GraphNode> seen) {
   if (seen.add(this)) {
     Collection<GraphNode> allKill = null;
     for (Iterator<GraphNode> i = pred.iterator(); i.hasNext(); ) {
       GraphNode pred = i.next();
       List<GraphNode> kill = visitor.visit(pred, this, arg1, arg2);
       if (kill != null) {
         if (allKill == null) allKill = new ArrayList<GraphNode>();
         allKill.addAll(kill);
       }
     }
     if (allKill != null) pred.removeAll(allKill);
     for (Iterator<GraphNode> i = pred.iterator(); i.hasNext(); ) {
       GraphNode pred = i.next();
       pred.doVisitPredecessors(visitor, arg1, arg2, seen);
     }
   }
 }
Ejemplo n.º 2
0
 /** Visit each predecessor of this node applying the given visitor. */
 public <Alpha, Beta> void visitPredecessors(Visitor<Alpha, Beta> visitor, Alpha arg1, Beta arg2) {
   List<GraphNode> kill = visitor.visit(this, null, arg1, arg2);
   if (kill != null) pred.removeAll(kill);
   doVisitPredecessors(visitor, arg1, arg2, new HashSet<GraphNode>());
 }