From b870629504692c0537d642bd8b9ef6c8a942b6c2 Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 22 Jan 2006 04:47:10 -0500 Subject: [PATCH] checkpoint darcs-hash:20060122094710-5007d-65055171c765ca78b0d83e58be3b08d1efb4ff98.gz --- src/edu/berkeley/sbp/Forest.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/edu/berkeley/sbp/Forest.java b/src/edu/berkeley/sbp/Forest.java index 378c069..4de9fa8 100644 --- a/src/edu/berkeley/sbp/Forest.java +++ b/src/edu/berkeley/sbp/Forest.java @@ -18,10 +18,13 @@ public abstract class Forest /*extends PrintableTree>*/ impl /** expand this forest into a set of trees */ public HashSet> expand(boolean toss) { - TreeMaker ret = new TreeMaker(toss); + final HashSet> hs = new HashSet>(); + TreeMaker ret = new TreeMaker(toss) { + public void add(Tree t) { hs.add(t); } + }; 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 Forest singleton(Input.Location loc) { return create(loc, null, new Forest[] { }, false, true); } @@ -123,10 +126,11 @@ public abstract class Forest /*extends PrintableTree>*/ impl } public abstract void visit(Invokable,B,C> ivbc, B b, C c); - private static class TreeMaker extends HashSet> implements Invokable,Boolean,Integer> { + private static abstract class TreeMaker /*extends HashSet>*/ implements Invokable,Boolean,Integer> { public ArrayList> toks = new ArrayList>(); private boolean toss; public TreeMaker(boolean toss) { this.toss = toss; } + public abstract void add(Tree t); public void invoke(Forest.Body bod, Boolean o, Integer i) { if (i==null) { ArrayList> toks = this.toks; -- 1.7.10.4