示例#1
0
 private void populatePreOrder(TreeNode<T> currentNode, final LinkedList<TreeNode<T>> stack) {
   List<TreeNode<T>> children = currentNode.getChildren();
   stack.addLast(currentNode);
   for (TreeNode<T> childNode : children) {
     populatePreOrder(childNode, stack);
   }
 }
示例#2
0
 public Iterator<TreeNode<T>> getPreOrderIter() {
   final LinkedList<TreeNode<T>> stack = new LinkedList<TreeNode<T>>();
   populatePreOrder(this, stack);
   return stack.iterator();
 }