1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-11-05 18:29:53 -08:00

Add a new function to add children into collection.

This commit is contained in:
Danila Fedorin 2017-07-24 20:45:56 -07:00
parent 02141d8df0
commit ac3087fc3f
2 changed files with 9 additions and 5 deletions

View File

@ -1,14 +1,13 @@
package org.nwapw.abacus.lexing.pattern; package org.nwapw.abacus.lexing.pattern;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
public class LinkNode<T> extends PatternNode<T> { public class LinkNode<T> extends PatternNode<T> {
@Override @Override
public void addInto(ArrayList<PatternNode<T>> into) { public void addInto(Collection<PatternNode<T>> into) {
for(PatternNode<T> node : outputStates){ addOutputsInto(into);
node.addInto(into);
}
} }
} }

View File

@ -1,6 +1,7 @@
package org.nwapw.abacus.lexing.pattern; package org.nwapw.abacus.lexing.pattern;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
public class PatternNode<T> { public class PatternNode<T> {
@ -19,8 +20,12 @@ public class PatternNode<T> {
return '\0'; return '\0';
} }
public void addInto(ArrayList<PatternNode<T>> into){ public void addInto(Collection<PatternNode<T>> into){
into.add(this); into.add(this);
} }
public void addOutputsInto(Collection<PatternNode<T>> into){
outputStates.forEach(e -> e.addInto(into));
}
} }