projects
/
sbp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
95f4a5c
)
make Result.usedByNonDoomedNode() more efficient
author
adam
<adam@megacz.com>
Mon, 26 Feb 2007 03:18:16 +0000
(22:18 -0500)
committer
adam
<adam@megacz.com>
Mon, 26 Feb 2007 03:18:16 +0000
(22:18 -0500)
darcs-hash:
20070226031816
-5007d-
707b2ef2091a7fc7cefaee5ebd132d8c5a06dd0c
.gz
src/edu/berkeley/sbp/Result.java
patch
|
blob
|
history
diff --git
a/src/edu/berkeley/sbp/Result.java
b/src/edu/berkeley/sbp/Result.java
index
6fc1ad2
..
10a9b94
100644
(file)
--- a/
src/edu/berkeley/sbp/Result.java
+++ b/
src/edu/berkeley/sbp/Result.java
@@
-17,21
+17,23
@@
final class Result implements GraphViz.ToGraphViz {
private Position reduction;
private HashSet<Node> children = new HashSet<Node>();
private boolean destroyed = false;
private Position reduction;
private HashSet<Node> children = new HashSet<Node>();
private boolean destroyed = false;
+ private int usedByNonDoomedNode = 0;
public Position reduction() { return reduction; }
public GSS.Phase phase() { return phase; }
public Forest getForest() { return f; }
public Node parent() { return parent; }
public Position reduction() { return reduction; }
public GSS.Phase phase() { return phase; }
public Forest getForest() { return f; }
public Node parent() { return parent; }
- public void addChild(Node child) { children.add(child); }
- public void removeChild(Node child) { children.remove(child); }
+ public void addChild(Node child) {
+ children.add(child);
+ usedByNonDoomedNode += child.state().doomed ? 0 : 1;
+ }
+ public void removeChild(Node child) {
+ children.remove(child);
+ usedByNonDoomedNode -= child.state().doomed ? 0 : 1;
+ }
public boolean usedByAnyNode() { return children.size() > 0; }
public boolean usedByAnyNode() { return children.size() > 0; }
- public boolean usedByNonDoomedNode() {
- for(Node n : children)
- if (!n.state().doomed)
- return true;
- return false;
- }
+ public boolean usedByNonDoomedNode() { return usedByNonDoomedNode > 0; }
public String toString() { return super.toString()+"->"+parent(); }
public String toString() { return super.toString()+"->"+parent(); }