public DependencyTreeInverseIterator( DependencyNode rootNode ) { DependencyTreePreorderIterator it = new DependencyTreePreorderIterator( rootNode ); while ( it.hasNext() ) { nodesToProcess.push( it.next() ); } }
/** * Gets an iterator that returns this dependency node and it's children in preorder traversal. * * @return the preorder traversal iterator * @see DependencyTreePreorderIterator */ public Iterator<DependencyNode> preorderIterator() { return new DependencyTreePreorderIterator( this ); }
public DependencyNode next() { if ( !hasNext() ) { throw new NoSuchElementException(); } DependencyNode currentNode = nodesToProcess.pop(); List<DependencyNode> children = currentNode.getChildren(); if ( children != null ) { for ( int i = children.size() - 1; i >= 0; i-- ) { nodesToProcess.push( children.get( i ) ); } } return currentNode; }