📄 queue.java
字号:
/* Name: Queue.java
* Author: Liu Lizhe
* Date Created: November 13,2004
* Description: Queue implementation in Java
*/
package com.LiuLizhe.util;
public class Queue extends java.util.Vector {
public Queue() {
super();
}
public synchronized void enQueue(Object x) {
super.addElement(x);
}
public synchronized Object deQueue() {
if(this.empty())
throw new EmptyQueueException();
Object x = super.elementAt(0);
super.removeElementAt(0);
return x;
}
public synchronized Object getHead() {
if(this.empty())
throw new EmptyQueueException();
return super.elementAt(0);
}
public boolean empty() {
return super.isEmpty();
}
public synchronized void clear() {
super.removeAllElements();
}
public int search(Object x) {
return super.indexOf(x);
}
public class EmptyQueueException extends java.lang.RuntimeException {
public EmptyQueueException() {
super();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -