链表实现栈
public class LinkStack {
private LinkList thisList;
public LinkStack(){
thisList = new LinkList();
}
public void push(int data){
thisList.insertFirst(data);
}
public int pop(){
return thisList.deleteFirst().data;
}
public boolean isEmpty(){
return thisList.isEmpty();
}
public void display(){
thisList.display();
}
}
链表实现队列
public class LinkQueue {
private DoubleEndedLink theList;
public LinkQueue() {
theList = new DoubleEndedLink();
}
public void insert(int data) {
theList.insertLast(data);
}
public int remove() {
return theList.deleteFirst().data;
}
public boolean isEmpty() {
return theList.isEmpty();
}
}
参考资料
文档信息
- 本文作者:Bob.Zhu
- 本文链接:https://adolphor.github.io/2021/04/14/04-stack-queue-by-link/
- 版权声明:自由转载-非商用-非衍生-保持署名(创意共享3.0许可证)