/** * Given a {@link FlowNodeVisitor}, invoke {@link FlowNodeVisitor#visit(FlowNode)} on each node and halt early if it returns false. * Includes null-checking on all but the visitor, to allow directly calling with unchecked inputs (simplifies use). * * Useful if you wish to collect some information from every node in the FlowGraph. * To do that, accumulate internal state in the visitor, and invoke a getter when complete. * @param heads Nodes to start walking the DAG backwards from. * @param blackList Nodes we can't visit or pass beyond. * @param visitor Visitor that will see each FlowNode encountered. */ public void visitAll(@CheckForNull Collection<FlowNode> heads, @CheckForNull Collection<FlowNode> blackList, @Nonnull FlowNodeVisitor visitor) { if (!setup(heads, blackList)) { return; } for (FlowNode f : this) { boolean canContinue = visitor.visit(f); if (!canContinue) { break; } } }