Пример #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();
 }