Mercurial > hg > Members > tatsuki > bench > jungle-core
diff src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/query/PathNodeIterator.java @ 153:20af7f25ef32
miner change
author | one |
---|---|
date | Tue, 25 Nov 2014 17:52:41 +0900 |
parents | 371b6ddb78f2 |
children | 3cd075a445bf |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/query/PathNodeIterator.java Sat Nov 22 15:25:09 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/query/PathNodeIterator.java Tue Nov 25 17:52:41 2014 +0900 @@ -3,14 +3,11 @@ import java.util.Iterator; import java.util.Stack; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNodeChildren; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Pair; -public class PathNodeIterator implements Iterator<Pair<TreeNode, NodePath>> { +public class PathNodeIterator implements Iterator<TreeNode> { - NodePath path; TreeNode root; TreeNode node; int childNumber; @@ -24,10 +21,9 @@ * otherwise traverse tree and create index * * */ - public PathNodeIterator(Pair<TreeNode,NodePath> pair) { - this.root = pair.left(); - path = pair.right(); - node = root; + public PathNodeIterator(TreeNode root) { + this.root = root; + this.node = root; } @Override @@ -36,13 +32,10 @@ } @Override - public Pair<TreeNode, NodePath> next() { + public TreeNode next() { TreeNode now = node; - NodePath currentPath = path; - // System.out.println("path = " + currentPath.toString()); if (node.getChildren().size() > 0) { // nodeStack.push(node); - path = path.add(0); children = node.getChildren(); node = children.at(0).b(); childNumber = 1; @@ -50,14 +43,12 @@ } else if (node == root) { node = null; // no more node children = null; - return new Pair<TreeNode, NodePath>(now, currentPath); + return now; }else if (children != null && children.size() > childNumber) { childNumber = searchStack.pop(); node = children.at(childNumber).b(); - path = path.tail().add(childNumber); searchStack.push(++childNumber); } else { - path = path.tail(); node = nodeStack.pop(); children = node.getChildren(); childNumber = searchStack.pop(); @@ -65,21 +56,19 @@ if (node == root) { node = null; // no more node children = null; - return new Pair<TreeNode, NodePath>(now, currentPath); + return now; } - path = path.tail(); node = nodeStack.pop(); children = node.getChildren(); childNumber = searchStack.pop(); } if (node != null && childNumber < children.size()) { - path = path.add(childNumber); nodeStack.push(node); node = children.at(childNumber).b(); searchStack.push(++childNumber); } } - return new Pair<TreeNode, NodePath>(now, currentPath); + return now; } @Override