From 5115f1d2a7eab41436debc696870953e18a1b236 Mon Sep 17 00:00:00 2001 From: student Date: Mon, 12 Feb 2018 13:56:22 -0500 Subject: General update --- base/src/bjc/dicelang/expr/Shunter.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'base/src/bjc/dicelang/expr/Shunter.java') diff --git a/base/src/bjc/dicelang/expr/Shunter.java b/base/src/bjc/dicelang/expr/Shunter.java index e4add67..a1b24cb 100644 --- a/base/src/bjc/dicelang/expr/Shunter.java +++ b/base/src/bjc/dicelang/expr/Shunter.java @@ -1,9 +1,10 @@ package bjc.dicelang.expr; -import java.util.ArrayList; import java.util.Deque; import java.util.LinkedList; -import java.util.List; + +import bjc.utils.funcdata.FunctionalList; +import bjc.utils.funcdata.IList; /** * Converts a infix series of tokens into a prefix series of tokens. @@ -11,9 +12,6 @@ import java.util.List; * @author Ben Culkin */ public class Shunter { - /* - * @NOTE Why does this method return an array, and not the list of tokens? - */ /** * Convert a infix series of tokens to a postfix series of tokens. * @@ -22,9 +20,9 @@ public class Shunter { * * @return The tokens in postfix order. */ - public static Token[] shuntTokens(final Token[] infixTokens) { + public static IList shuntTokens(final Token[] infixTokens) { /* The returned tokens. */ - final List postfixTokens = new ArrayList<>(infixTokens.length); + final IList postfixTokens = new FunctionalList<>(); /* The current stack of operators. */ final Deque opStack = new LinkedList<>(); @@ -98,6 +96,6 @@ public class Shunter { postfixTokens.add(opStack.pop()); } - return postfixTokens.toArray(new Token[0]); + return postfixTokens; } } -- cgit v1.2.3