@Override public void reset() { super.reset(); currentElementIndex = 0; p = 0; prevElement = null; }
firstTime = false; if ( adaptor.getChildCount(tree)==0 ) { // single node tree (special) nodes.add(eof); return tree; if ( nodes!=null && nodes.size()>0 ) return nodes.remove(); nodes.add(tree); // real node is next after DOWN return down; adaptor.getChildIndex(tree)+1 >= adaptor.getChildCount(parent) ) nodes.add(up); // we're moving back up tree = parent; parent = adaptor.getParent(tree); nodes.add(eof); // add to queue, might have UP nodes in there return nodes.remove(); nodes.add(tree); // add to queue, might have UP nodes in there return nodes.remove();
public void reset() { firstTime = true; tree = root; nodes.clear(); }
@Override public boolean hasNext() { if ( firstTime ) return root!=null; if ( nodes!=null && nodes.size()>0 ) return true; if ( tree==null ) return false; if ( adaptor.getChildCount(tree)>0 ) return true; return adaptor.getParent(tree)!=null; // back at root? }
public TreeIterator(TreeAdaptor adaptor, Object tree) { this.adaptor = adaptor; this.tree = tree; this.root = tree; nodes = new FastQueue<Object>(); down = adaptor.create(Token.DOWN, "DOWN"); up = adaptor.create(Token.UP, "UP"); eof = adaptor.create(Token.EOF, "EOF"); }
public T head() { return elementAt(0); }
firstTime = false; if ( adaptor.getChildCount(tree)==0 ) { // single node tree (special) nodes.add(eof); return tree; if ( nodes!=null && nodes.size()>0 ) return nodes.remove(); nodes.add(tree); // real node is next after DOWN return down; adaptor.getChildIndex(tree)+1 >= adaptor.getChildCount(parent) ) nodes.add(up); // we're moving back up tree = parent; parent = adaptor.getParent(tree); nodes.add(eof); // add to queue, might have UP nodes in there return nodes.remove(); nodes.add(tree); // add to queue, might have UP nodes in there return nodes.remove();
public void reset() { firstTime = true; tree = root; nodes.clear(); }
@Override public boolean hasNext() { if ( firstTime ) return root!=null; if ( nodes!=null && nodes.size()>0 ) return true; if ( tree==null ) return false; if ( adaptor.getChildCount(tree)>0 ) return true; return adaptor.getParent(tree)!=null; // back at root? }
public TreeIterator(TreeAdaptor adaptor, Object tree) { this.adaptor = adaptor; this.tree = tree; this.root = tree; nodes = new FastQueue<Object>(); down = adaptor.create(Token.DOWN, "DOWN"); up = adaptor.create(Token.UP, "UP"); eof = adaptor.create(Token.EOF, "EOF"); }
public T head() { return elementAt(0); }
firstTime = false; if ( adaptor.getChildCount(tree)==0 ) { // single node tree (special) nodes.add(eof); return tree; if ( nodes!=null && nodes.size()>0 ) return nodes.remove(); nodes.add(tree); // real node is next after DOWN return down; adaptor.getChildIndex(tree)+1 >= adaptor.getChildCount(parent) ) nodes.add(up); // we're moving back up tree = parent; parent = adaptor.getParent(tree); nodes.add(eof); // add to queue, might have UP nodes in there return nodes.remove(); nodes.add(tree); // add to queue, might have UP nodes in there return nodes.remove();
public void reset() { firstTime = true; tree = root; nodes.clear(); }
@Override public void reset() { super.reset(); currentElementIndex = 0; p = 0; prevElement = null; }
@Override public boolean hasNext() { if ( firstTime ) return root!=null; if ( nodes!=null && nodes.size()>0 ) return true; if ( tree==null ) return false; if ( adaptor.getChildCount(tree)>0 ) return true; return adaptor.getParent(tree)!=null; // back at root? }