📄 sequencestack.java
字号:
/**
* Created by IntelliJ IDEA.
* User: Administrator
* Date: 2009-2-3
* Time: 14:42:29
* To change this template use File | Settings | File Templates.
*/
public class SequenceStack {
int[] stack;
int top;
int stackSize;
public void initStack(int size) {
stack = new int[size];
stackSize = size;
top = 0;
}
public void destoryStack() {
stack = null;
stackSize = top = 0;
}
public void clearStack() {
top = 0;
}
public boolean stackEmpty() {
return top == 0;
}
public boolean stackFull() {
return top == stackSize;
}
public int stackLength() {
return top;
}
public int getTop() {
if (stackEmpty()) {
return -100000;
}
return stack[top - 1];
}
public boolean push(int val) {
if (stackFull()) {
return false;
}
stack[top++] = val;
return true;
}
public int pop() {
if (stackEmpty()) {
return -100000;
}
return stack[--top];
}
public void stackTraverse(){
for(int i=top;i>0;){
System.out.print(stack[--i]);
}
System.out.println();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -