Exemplo n.º 1
0
 public Forest(List<Tree> roots) {
   this.roots = roots;
   size = 0;
   for (Tree root : roots) {
     size += root.size();
   }
 }
Exemplo n.º 2
0
  /**
   * 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);
  }
Exemplo n.º 3
0
  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);
    }
  }
Exemplo n.º 4
0
 public Forest(Tree singleRoot) {
   this.roots = Collections.singletonList(singleRoot);
   size = singleRoot.size();
 }