Exemplo n.º 1
0
    public TreeNode nextElement() {
      Enumeration enumer = (Enumeration) queue.firstObject();
      TreeNode node = (TreeNode) enumer.nextElement();
      Enumeration children = node.children();

      if (!enumer.hasMoreElements()) {
        queue.dequeue();
      }
      if (children.hasMoreElements()) {
        queue.enqueue(children);
      }
      return node;
    }
Exemplo n.º 2
0
 public BreadthFirstEnumeration(TreeNode rootNode) {
   super();
   Vector<TreeNode> v = new Vector<TreeNode>(1);
   v.addElement(rootNode); // PENDING: don't really need a vector
   queue = new Queue();
   queue.enqueue(v.elements());
 }
Exemplo n.º 3
0
 public boolean hasMoreElements() {
   return (!queue.isEmpty() && ((Enumeration) queue.firstObject()).hasMoreElements());
 }