public Forest(List<Tree> roots) { this.roots = roots; size = 0; for (Tree root : roots) { size += root.size(); } }
/** * Forest From Postorder --------------------- Given a sublist of nodes from the postorder, turn * it into a rooted subforest * * @param subforestPostorder * @return */ public static Forest forestFromPostorder(List<Tree> postorder) { List<Tree> roots = new ArrayList<Tree>(); int currIndex = postorder.size() - 1; while (currIndex >= 0) { Tree root = postorder.get(currIndex); roots.add(root); currIndex -= root.size(); } throw new RuntimeException("weary"); // return new Forest(roots); }
public void run() { for (int i = 0; i < m; i++) { noncritical(); tree.traverseUpFrom(node, i); critical(); Start.out.print(tree); long now = System.currentTimeMillis(); Start.out.println("UnixTime=" + (now - Start.start_time)); Start.runtimes = Start.runtimes + "p[" + (node - tree.size() + 1) + "-" + i + "]:" + (now - Start.start_time) + "\n"; tree.traverseDownto(node / 2); } }
public Forest(Tree singleRoot) { this.roots = Collections.singletonList(singleRoot); size = singleRoot.size(); }