mirror of
https://github.com/zeroflag/fcl.git
synced 2025-01-11 20:01:10 +01:00
generic
This commit is contained in:
parent
e2eac14a57
commit
b20ef173df
3 changed files with 11 additions and 13 deletions
|
@ -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<Obj> stack = new LStack<>();
|
||||
|
||||
static {
|
||||
FclTypeAdapter typeAdapter = new FclTypeAdapter();
|
||||
|
|
|
@ -14,8 +14,8 @@ import java.util.Set;
|
|||
public class Juggler {
|
||||
private final List<Obj> input;
|
||||
private final List<Obj> output;
|
||||
private final LStack stack;
|
||||
private final LStack rstack;
|
||||
private final LStack<Obj> stack;
|
||||
private final LStack<Obj> rstack;
|
||||
private final Set<Obj> uniqueOutput;
|
||||
private final List<Integer> code;
|
||||
private final List<Word> 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);
|
||||
|
|
|
@ -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<Obj> {
|
||||
public final class LStack<T> extends ArrayList<T> {
|
||||
public LStack() {
|
||||
super(10);
|
||||
}
|
||||
|
||||
public LStack(final Collection<Obj> collection) {
|
||||
public LStack(final Collection<T> 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);
|
||||
|
|
Loading…
Reference in a new issue