mirror of
https://github.com/CyC2018/CS-Notes.git
synced 2025-07-10 21:40:55 +08:00
auto commit
This commit is contained in:
@ -302,9 +302,11 @@ public class Queue<Item> {
|
|||||||
|
|
||||||
// 出队列
|
// 出队列
|
||||||
public Item dequeue() {
|
public Item dequeue() {
|
||||||
|
if (isEmpty()) return null;
|
||||||
Node node = first;
|
Node node = first;
|
||||||
first = first.next;
|
first = first.next;
|
||||||
N--;
|
N--;
|
||||||
|
if (isEmpty()) last = null;
|
||||||
return node.item;
|
return node.item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user