From b20ef173dfb8873568cf7afaf2b56d3951cc91f9 Mon Sep 17 00:00:00 2001 From: zeroflag Date: Thu, 12 Aug 2021 11:17:05 +0200 Subject: [PATCH] generic --- src/main/java/com/vectron/fcl/FclStack.java | 2 +- src/main/java/com/vectron/fcl/Juggler.java | 8 ++++---- src/main/java/com/vectron/fcl/LStack.java | 14 ++++++-------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/vectron/fcl/FclStack.java b/src/main/java/com/vectron/fcl/FclStack.java index e56716e..f2c4737 100644 --- a/src/main/java/com/vectron/fcl/FclStack.java +++ b/src/main/java/com/vectron/fcl/FclStack.java @@ -15,7 +15,7 @@ import java.util.List; public class FclStack { private static final Gson gson; - private final LStack stack = new LStack(); + private final LStack stack = new LStack<>(); static { FclTypeAdapter typeAdapter = new FclTypeAdapter(); diff --git a/src/main/java/com/vectron/fcl/Juggler.java b/src/main/java/com/vectron/fcl/Juggler.java index 9cf3fd8..26a2dea 100644 --- a/src/main/java/com/vectron/fcl/Juggler.java +++ b/src/main/java/com/vectron/fcl/Juggler.java @@ -14,8 +14,8 @@ import java.util.Set; public class Juggler { private final List input; private final List output; - private final LStack stack; - private final LStack rstack; + private final LStack stack; + private final LStack rstack; private final Set uniqueOutput; private final List code; private final List availableWords; @@ -81,8 +81,8 @@ public class Juggler { this.output = output; this.maxSteps = maxSteps; this.uniqueOutput = new HashSet<>(output); - this.stack = new LStack(); - this.rstack = new LStack(); + this.stack = new LStack<>(); + this.rstack = new LStack<>(); this.code = new ArrayList<>(); this.availableWords = populateWords(excluded); this.code.add(0); diff --git a/src/main/java/com/vectron/fcl/LStack.java b/src/main/java/com/vectron/fcl/LStack.java index a0885dc..186456a 100644 --- a/src/main/java/com/vectron/fcl/LStack.java +++ b/src/main/java/com/vectron/fcl/LStack.java @@ -1,31 +1,29 @@ package com.vectron.fcl; -import com.vectron.fcl.types.Obj; - import java.util.ArrayList; import java.util.Collection; import java.util.EmptyStackException; -public final class LStack extends ArrayList { +public final class LStack extends ArrayList { public LStack() { super(10); } - public LStack(final Collection collection) { + public LStack(final Collection collection) { super(collection); } - public void push(Obj item) { + public void push(T item) { add(item); } - public Obj pop() { - Obj top = peek(); + public T pop() { + T top = peek(); remove(size() - 1); return top; } - public Obj peek() { + public T peek() { int size = size(); if (size == 0) throw new EmptyStackException(); return get(size - 1);