# HG changeset patch # User one # Date 1283096930 -32400 # Node ID 423a01ec2d325f883f7d5387a4c383579ead080b # Parent cc89a466492745767ee4a7c27ab5907c085eacda findPath and cloneTree in PreorderTreewalker1 (not yet tested) diff -r cc89a4664927 -r 423a01ec2d32 src/treecms/proto/test/PreOrderTreeWalker.java --- a/src/treecms/proto/test/PreOrderTreeWalker.java Mon Aug 30 00:05:44 2010 +0900 +++ b/src/treecms/proto/test/PreOrderTreeWalker.java Mon Aug 30 00:48:50 2010 +0900 @@ -22,28 +22,25 @@ } class IteratorState implements Iterator { LinkedListnodeStack; - List children; int position; NodeAPI current, next; IteratorState(NodeAPI root) { current = root; - children = root.getChildList(); position = 0; nodeStack = new LinkedList(); } public boolean hasNext() { - while (position>=children.size()) { + while (position>=current.getChildList().size()) { if (nodeStack.isEmpty()) return false; - children = nodeStack.getLast().node.getChildList(); - position = nodeStack.getLast().position; - nodeStack.removeLast(); + NodeState s = nodeStack.poll(); + current = s.node; + position = s.position; } - next = children.get(position++); + next = current.getChildList().get(position++); if (! next.getChildList().isEmpty()) { nodeStack.addLast(new NodeState(current,position)); current = next; - children = next.getChildList(); position = 0; } return true;