fila.java
来自「FTPCommand是一个在嵌入式环境(WindowsCE」· Java 代码 · 共 57 行
JAVA
57 行
package util;
public class Fila {
public Node top;
private Node tail;
public int length;
public Fila() {
length = 0;
top = null;
tail = null;
}
public void enfileirar(Object object) {
Node n = new Node(object, null);
if (top != null) {
Node t = tail;
t.next = n;
tail = n;
} else top = tail = n;
length++;
}
/**
* @return null if queue is Empty;
*/
public Object desenfileirar() {
if (length == 0) return null;
else if (length == 1) {
Node t = top;
top = tail = null;
length--;
return t.object;
} else {
Node t = top;
top = t.next;
length--;
return t.object;
}
}
}
class Node {
public Object object;
public Node next;
public Node(Object object, Node next) {
this.object = object;
this.next = next;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?