/** * Creates a new postorder list generator. */ public PostorderNodeListGenerator() { visits = new Stack<Boolean>(); }
public boolean visitLeave( DependencyNode node ) { parents.pop(); return true; }
public boolean visitEnter( DependencyNode node ) { boolean accept = filter == null || filter.accept( node, parents ); parents.push( node ); if ( accept ) { DependencyNode[] path = new DependencyNode[parents.size()]; int i = parents.size() - 1; for ( DependencyNode n : parents ) { path[i] = n; i--; } paths.add( Arrays.asList( path ) ); } return !( excludeChildrenOfMatches && accept ); }
public boolean visitEnter( DependencyNode node ) { boolean recurse = true; DependencyNode clone = clones.get( node ); if ( clone == null ) { clone = clone( node ); clones.put( node, clone ); } else { recurse = false; } DependencyNode parent = parents.peek(); if ( parent == null ) { root = clone; } else { parent.getChildren().add( clone ); } parents.push( clone ); return recurse; }
public boolean visitEnter( DependencyNode node ) { boolean visited = visitedNodes.put( node, Boolean.TRUE ) != null; visits.push( Boolean.valueOf( visited ) ); if ( visited ) { return false; } return visitor.visitEnter( node ); }
@Override public boolean visitEnter( DependencyNode node ) { boolean visited = !setVisited( node ); visits.push( Boolean.valueOf( visited ) ); if ( visited ) { return false; } return true; }
/** * Creates a new visitor that clones the visited nodes. */ public CloningDependencyVisitor() { parents = new Stack<DependencyNode>(); clones = new IdentityHashMap<DependencyNode, DependencyNode>( 256 ); }
public boolean visitLeave( DependencyNode node ) { parents.pop(); return true; }
/** * Creates a new visitor that delegates traversal of nodes matching the given filter to the specified visitor. * * @param visitor The visitor to delegate to, must not be {@code null}. * @param filter The filter to apply, may be {@code null} to not filter. */ public FilteringDependencyVisitor( DependencyVisitor visitor, DependencyFilter filter ) { if ( visitor == null ) { throw new IllegalArgumentException( "dependency visitor not specified" ); } this.visitor = visitor; this.filter = filter; this.accepts = new Stack<Boolean>(); this.parents = new Stack<DependencyNode>(); }
/** * Creates a new visitor that uses the specified filter to identify terminal nodes of interesting paths. * * @param filter The filter used to select terminal nodes of paths to record, may be {@code null} to match any node. * @param excludeChildrenOfMatches Flag controlling whether children of matched nodes should be excluded from the * traversal, thereby ignoring any potential paths to other matching nodes beneath a matching ancestor * node. If {@code true}, all recorded paths will have only one matching node (namely the terminal node), * if {@code false} a recorded path can consist of multiple matching nodes. */ public PathRecordingDependencyVisitor( DependencyFilter filter, boolean excludeChildrenOfMatches ) { this.filter = filter; this.excludeChildrenOfMatches = excludeChildrenOfMatches; paths = new ArrayList<List<DependencyNode>>(); parents = new Stack<DependencyNode>(); }
public boolean visitLeave( DependencyNode node ) { Boolean visited = visits.pop(); if ( visited.booleanValue() ) { return true; } return visitor.visitLeave( node ); }
/** * Creates a new visitor that delegates to the specified visitor. * * @param visitor The visitor to delegate to, must not be {@code null}. */ public TreeDependencyVisitor( DependencyVisitor visitor ) { if ( visitor == null ) { throw new IllegalArgumentException( "no visitor delegate specified" ); } this.visitor = visitor; visitedNodes = new IdentityHashMap<DependencyNode, Object>( 512 ); visits = new Stack<Boolean>(); }
@Override public boolean visitLeave( DependencyNode node ) { Boolean visited = visits.pop(); if ( visited.booleanValue() ) { return true; } if ( node.getDependency() != null ) { nodes.add( node ); } return true; }