1 // Copyright 2006-2007 all rights reserved; see LICENSE file for BSD-style license
3 package edu.berkeley.sbp;
4 import edu.berkeley.sbp.util.*;
5 import edu.berkeley.sbp.Sequence.Pos;
6 import edu.berkeley.sbp.Sequence.Pos;
10 extends Node<StateNode> {
12 private Pos reduction;
13 private Forest.Many f = new Forest.Many();
15 public void merge(Forest newf) { this.f.merge(newf); }
16 public Pos reduction() { return reduction; }
17 public boolean isDoomedState() { /* this is irrelevant */ return false; }
18 public Forest getForest() { return f; }
19 public String toString() { return super.toString()+"->"+phase(); }
20 public boolean hasPathToRoot() {
21 if (predecessorPhase()==null) return true;
22 return super.hasPathToRoot();
26 if (destroyed) return;
27 if (!hasSuccessors() || !hasPredecessors()) destroy();
29 protected void destroy() {
30 if (destroyed) return;
31 if (predecessorPhase()==null) return; // never destroy the "primordeal" result
35 protected void addPred(StateNode pred) {
37 // results should have at most one predecessor
38 //if (predecessors.size() > 1) throw new Error();
41 public ResultNode() { this(null, null, null); }
42 public ResultNode(Forest f, Pos reduction, StateNode pred) {
43 super(pred==null ? null : pred.phase(),
44 pred==null ? null : pred.phase());
46 this.reduction = reduction;
47 if (pred != null) addPred(pred);