diff --git a/src/org/nwapw/abacus/lexing/pattern/LinkNode.java b/src/org/nwapw/abacus/lexing/pattern/LinkNode.java index 69b16ed..460c418 100644 --- a/src/org/nwapw/abacus/lexing/pattern/LinkNode.java +++ b/src/org/nwapw/abacus/lexing/pattern/LinkNode.java @@ -1,14 +1,13 @@ package org.nwapw.abacus.lexing.pattern; import java.util.ArrayList; +import java.util.Collection; public class LinkNode extends PatternNode { @Override - public void addInto(ArrayList> into) { - for(PatternNode node : outputStates){ - node.addInto(into); - } + public void addInto(Collection> into) { + addOutputsInto(into); } } diff --git a/src/org/nwapw/abacus/lexing/pattern/PatternNode.java b/src/org/nwapw/abacus/lexing/pattern/PatternNode.java index 3ef36d7..4c0908a 100644 --- a/src/org/nwapw/abacus/lexing/pattern/PatternNode.java +++ b/src/org/nwapw/abacus/lexing/pattern/PatternNode.java @@ -1,6 +1,7 @@ package org.nwapw.abacus.lexing.pattern; import java.util.ArrayList; +import java.util.Collection; import java.util.HashSet; public class PatternNode { @@ -19,8 +20,12 @@ public class PatternNode { return '\0'; } - public void addInto(ArrayList> into){ + public void addInto(Collection> into){ into.add(this); } + public void addOutputsInto(Collection> into){ + outputStates.forEach(e -> e.addInto(into)); + } + }