Esempio n. 1
0
 public TreeNode nextElement() {
   try {
     return stack.pop();
   } catch (EmptyStackException e) {
     throw new NoSuchElementException("No more elements");
   }
 }
Esempio n. 2
0
    public TreeNode nextElement() {
      Enumeration enumer = stack.peek();
      TreeNode node = (TreeNode) enumer.nextElement();
      Enumeration children = node.children();

      if (!enumer.hasMoreElements()) {
        stack.pop();
      }
      if (children.hasMoreElements()) {
        stack.push(children);
      }
      return node;
    }