+ public Tree<T> expand1() throws Ambiguous {
+ Tree<T>[] ret = new Tree[children.length];
+ for(int i=0; i<children.length; i++)
+ ret[i] = children[i].expand1();
+ return new Tree<T>(location, head, ret, unwrap);
+ }
+ public void gather(HashSet<Forest<T>> hf) {
+ hf.add(this);
+ for(Forest<T> f : children) f.gather(hf);
+ }
+ public void expand(HashSet<Tree<T>> ht, HashSet<Forest<T>> ignore, Tree<T> bogus) {
+ if (ignore.contains(this)) { ht.add(bogus); return; }
+ expand(0, new Tree[children.length], ht, ignore, bogus);
+ }
+ public void expand(final int i, Tree<T>[] ta, HashSet<Tree<T>> ht, HashSet<Forest<T>> ignore, Tree<T> bogus) {
+ if (i==children.length) {
+ ht.add(new Tree<T>(location, head, ta, unwrap));
+ } else {
+ HashSet<Tree<T>> ht2 = new HashSet<Tree<T>>();
+ children[i].expand(ht2, ignore, bogus);
+ for(Tree<T> tc : ht2) {
+ ta[i] = tc;
+ expand(i+1, ta, ht, ignore, bogus);
+ ta[i] = null;
+ }