栈和队列
来源:互联网 发布:马曳 知乎 编辑:程序博客网 时间:2024/06/06 11:36
public class Queue { private Element head; private Element tail; public int size; public void enqueue(Element e){ if(tail == null){ head = e; tail = e; }else{ tail.next = e; tail = e; } size++; } public Element dequeue(){ if(head == null){ return null; }else{ Element p = head; head = head.next; p.next = null; if(head == null){ tail = null; } size--; return p; } }}
public class Stack { public Element top; public int sum; public Element pop(){ if(top == null){ return null; }else{ Element p = top; sum -= top.value; top = top.next; p.next = null; return p; } } public void push(Element e){ if(top == null){ top = e; }else{ e.next = top; top = e; } sum += e.value; }}
0 0
- 栈和队列--队列
- 【栈和队列】队列
- 栈、队列和优先队列
- 栈和队列(队列)
- 栈和队列--栈
- 【栈和队列】栈
- 栈和队列
- 栈和队列
- 表、栈和队列
- 栈和队列
- 栈和队列应用
- 栈和队列
- 栈和队列
- 栈和队列
- 栈和队列
- 栈和队列
- 队列和栈
- 栈和队列 小结
- 第一个项目(Maven学习3)
- 8c 利用定时器实现时钟
- uva 10801(乘电梯dijkstra)
- codefroces 482C Game with Strings (概率dp神题)
- Food Delivery - ZOJ 3469 dp
- 栈和队列
- 机器学习中的数据清洗与特征处理综述
- 寒假水题集
- HTML网页中插入本地音乐
- iOS 折线图 ARLineChart-master
- 闻名不如见面——三层
- ubuntu的xorg的配置文件通过/var/log/Xorg.0.log查看位置
- 使用Event Bus模式解耦Android App组件间通信
- leetcode First Missing Positive