From fd0a1a0a63818fc1098b01b561c636457c1284ba Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Wed, 11 May 2016 21:11:29 -0400 Subject: Minor changes --- .../src/main/java/bjc/utils/parserutils/ShuntingYard.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/parserutils/ShuntingYard.java') diff --git a/BJC-Utils2/src/main/java/bjc/utils/parserutils/ShuntingYard.java b/BJC-Utils2/src/main/java/bjc/utils/parserutils/ShuntingYard.java index 8118faa..c1cd5c7 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/parserutils/ShuntingYard.java +++ b/BJC-Utils2/src/main/java/bjc/utils/parserutils/ShuntingYard.java @@ -63,12 +63,11 @@ public class ShuntingYard { } private final class TokenShunter implements Consumer { - private IList output; + private IList output; private Deque stack; private Function transform; - public TokenShunter(IList outpt, - Deque stack, + public TokenShunter(IList outpt, Deque stack, Function transform) { this.output = outpt; this.stack = stack; @@ -176,8 +175,7 @@ public class ShuntingYard { * The function to use to transform strings to tokens * @return A list of tokens in postfix notation */ - public IList postfix( - IList input, + public IList postfix(IList input, Function tokenTransformer) { if (input == null) { throw new NullPointerException("Input must not be null"); @@ -191,9 +189,8 @@ public class ShuntingYard { input.forEach(new TokenShunter(output, stack, tokenTransformer)); - while (!stack.isEmpty()) { - output.add(tokenTransformer.apply(stack.pop())); - } + stack.forEach( + (token) -> output.add(tokenTransformer.apply(token))); return output; } -- cgit v1.2.3