projects
/
sbp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
checkpoint
[sbp.git]
/
src
/
edu
/
berkeley
/
sbp
/
Forest.java
diff --git
a/src/edu/berkeley/sbp/Forest.java
b/src/edu/berkeley/sbp/Forest.java
index
378c069
..
4de9fa8
100644
(file)
--- a/
src/edu/berkeley/sbp/Forest.java
+++ b/
src/edu/berkeley/sbp/Forest.java
@@
-18,10
+18,13
@@
public abstract class Forest<T> /*extends PrintableTree<Forest.MyBody<T>>*/ impl
/** expand this forest into a set of trees */
public HashSet<Tree<T>> expand(boolean toss) {
/** expand this forest into a set of trees */
public HashSet<Tree<T>> expand(boolean toss) {
- TreeMaker<T> ret = new TreeMaker<T>(toss);
+ final HashSet<Tree<T>> hs = new HashSet<Tree<T>>();
+ TreeMaker<T> ret = new TreeMaker<T>(toss) {
+ public void add(Tree<T> t) { hs.add(t); }
+ };
visit(ret, null, null);
visit(ret, null, null);
- if (toss && ret.size() > 1) throw new Ambiguous(this);
- return ret;
+ if (toss && hs.size() > 1) throw new Ambiguous(this);
+ return hs;
}
static <T> Forest<T> singleton(Input.Location loc) { return create(loc, null, new Forest[] { }, false, true); }
}
static <T> Forest<T> singleton(Input.Location loc) { return create(loc, null, new Forest[] { }, false, true); }
@@
-123,10
+126,11
@@
public abstract class Forest<T> /*extends PrintableTree<Forest.MyBody<T>>*/ impl
}
public abstract <B,C> void visit(Invokable<Forest.Body<T>,B,C> ivbc, B b, C c);
}
public abstract <B,C> void visit(Invokable<Forest.Body<T>,B,C> ivbc, B b, C c);
- private static class TreeMaker<T> extends HashSet<Tree<T>> implements Invokable<Forest.Body<T>,Boolean,Integer> {
+ private static abstract class TreeMaker<T> /*extends HashSet<Tree<T>>*/ implements Invokable<Forest.Body<T>,Boolean,Integer> {
public ArrayList<Tree<T>> toks = new ArrayList<Tree<T>>();
private boolean toss;
public TreeMaker(boolean toss) { this.toss = toss; }
public ArrayList<Tree<T>> toks = new ArrayList<Tree<T>>();
private boolean toss;
public TreeMaker(boolean toss) { this.toss = toss; }
+ public abstract void add(Tree<T> t);
public void invoke(Forest.Body<T> bod, Boolean o, Integer i) {
if (i==null) {
ArrayList<Tree<T>> toks = this.toks;
public void invoke(Forest.Body<T> bod, Boolean o, Integer i) {
if (i==null) {
ArrayList<Tree<T>> toks = this.toks;