栈
public class Stack {
private long[] stackArray;
private int maxSize;
private int top;
public Stack(int maxSize) {
this.maxSize = maxSize;
this.stackArray = new long[this.maxSize];
this.top = -1;
}
public void push(long value) {
stackArray[++top] = value;
}
public long pop() {
return stackArray[top--];
}
public long peek() {
return stackArray[top];
}
public boolean isEmpty() {
return top == -1 ? true : false;
}
public boolean isFull() {
return top == (maxSize - 1) ? true : false;
}
}

浙公网安备 33010602011771号