projects
/
sbp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
93a050e
)
checkpoint
author
adam
<adam@megacz.com>
Sun, 22 Jan 2006 09:47:10 +0000
(
04:47
-0500)
committer
adam
<adam@megacz.com>
Sun, 22 Jan 2006 09:47:10 +0000
(
04:47
-0500)
darcs-hash:
20060122094710
-5007d-
65055171c765ca78b0d83e58be3b08d1efb4ff98
.gz
src/edu/berkeley/sbp/Forest.java
patch
|
blob
|
history
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;