双向循环队列解析
来源:互联网 发布:软件著作权 专利 编辑:程序博客网 时间:2024/05/21 09:09
双向循环队列是在循环队列的基础之上,
public class Deque { private int maxSize; private int left; private int right; private int nItems; private long[] myDeque; //constructor public Deque(int maxSize){ this.maxSize = maxSize; this.myDeque = new long[this.maxSize]; this.nItems = 0; this.left = this.maxSize; this.right = -1; } //insert a number into left side public void insertLeft(long n){ if(this.left==0) this.left = this.maxSize; this.myDeque[--this.left] = n; this.nItems++; } //insert a number into right side public void insertRight(long n){ if(this.right==this.maxSize-1) this.right = -1; this.myDeque[++this.right] = n; this.nItems++; } //remove from left public long removeLeft(){ long temp = this.myDeque[this.left++]; if(this.left==this.maxSize) this.left = 0; this.nItems--; return temp; } //remove from right public long removeRight(){ long temp = this.myDeque[this.right--]; if(this.left==-1) this.left = this.maxSize-1; this.nItems--; return temp; } //return true if deQue is empty public boolean isEmpty(){ return (this.nItems==0); } //return size of the deQue public int size(){ return this.nItems; } }
- 双向循环队列解析
- 双向循环队列解析
- 双向循环队列
- 双向循环队列
- 双向循环队列
- hdu1195Open the Lock(双向bfs+循环队列)
- 算法导论 顺序循环双向队列
- 数据结构:双向链表实现队列与循环链表
- 队列实现 (双向循环链表 C++)
- C语言使用非循环双向链表实现队列
- 数据结构---双向链表实现队列与循环链表
- 双向队列
- 双向队列
- 双向队列
- 双向队列
- 双向队列
- 双向队列
- 双向队列
- error loading midas.dll问题
- linux select详解
- 中小企业OA系统视频教程(更新程度:完毕)送ppt源码
- java中的设计模式(二)--工厂方法模式 反射机制
- WebSphere portal与Domino单点登录配置
- 双向循环队列解析
- solaris 的vi使用方法
- MapKit学习笔记
- Java软件工程师面试
- SSO单点登陆方案
- Windows下如何用putty连接Amazon EC2
- Eclipse+MyEclipse 中 package ,Source Folder ,folder的区别
- 重建redolog(裸设备)
- Lotus script 技巧