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 {
|
public class FclStack {
|
||||||
private static final Gson gson;
|
private static final Gson gson;
|
||||||
private final LStack stack = new LStack();
|
private final LStack<Obj> stack = new LStack<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
FclTypeAdapter typeAdapter = new FclTypeAdapter();
|
FclTypeAdapter typeAdapter = new FclTypeAdapter();
|
||||||
|
|
|
@ -14,8 +14,8 @@ import java.util.Set;
|
||||||
public class Juggler {
|
public class Juggler {
|
||||||
private final List<Obj> input;
|
private final List<Obj> input;
|
||||||
private final List<Obj> output;
|
private final List<Obj> output;
|
||||||
private final LStack stack;
|
private final LStack<Obj> stack;
|
||||||
private final LStack rstack;
|
private final LStack<Obj> rstack;
|
||||||
private final Set<Obj> uniqueOutput;
|
private final Set<Obj> uniqueOutput;
|
||||||
private final List<Integer> code;
|
private final List<Integer> code;
|
||||||
private final List<Word> availableWords;
|
private final List<Word> availableWords;
|
||||||
|
@ -81,8 +81,8 @@ public class Juggler {
|
||||||
this.output = output;
|
this.output = output;
|
||||||
this.maxSteps = maxSteps;
|
this.maxSteps = maxSteps;
|
||||||
this.uniqueOutput = new HashSet<>(output);
|
this.uniqueOutput = new HashSet<>(output);
|
||||||
this.stack = new LStack();
|
this.stack = new LStack<>();
|
||||||
this.rstack = new LStack();
|
this.rstack = new LStack<>();
|
||||||
this.code = new ArrayList<>();
|
this.code = new ArrayList<>();
|
||||||
this.availableWords = populateWords(excluded);
|
this.availableWords = populateWords(excluded);
|
||||||
this.code.add(0);
|
this.code.add(0);
|
||||||
|
|
|
@ -1,31 +1,29 @@
|
||||||
package com.vectron.fcl;
|
package com.vectron.fcl;
|
||||||
|
|
||||||
import com.vectron.fcl.types.Obj;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.EmptyStackException;
|
import java.util.EmptyStackException;
|
||||||
|
|
||||||
public final class LStack extends ArrayList<Obj> {
|
public final class LStack<T> extends ArrayList<T> {
|
||||||
public LStack() {
|
public LStack() {
|
||||||
super(10);
|
super(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LStack(final Collection<Obj> collection) {
|
public LStack(final Collection<T> collection) {
|
||||||
super(collection);
|
super(collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void push(Obj item) {
|
public void push(T item) {
|
||||||
add(item);
|
add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Obj pop() {
|
public T pop() {
|
||||||
Obj top = peek();
|
T top = peek();
|
||||||
remove(size() - 1);
|
remove(size() - 1);
|
||||||
return top;
|
return top;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Obj peek() {
|
public T peek() {
|
||||||
int size = size();
|
int size = size();
|
||||||
if (size == 0) throw new EmptyStackException();
|
if (size == 0) throw new EmptyStackException();
|
||||||
return get(size - 1);
|
return get(size - 1);
|
||||||
|
|
Loading…
Reference in a new issue