forked from Reaper622/DataStructure-Algorithm-TS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueue.js
More file actions
28 lines (28 loc) · 682 Bytes
/
Copy pathQueue.js
File metadata and controls
28 lines (28 loc) · 682 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"use strict";
exports.__esModule = true;
var Queue = /** @class */ (function () {
function Queue() {
this.queue = [];
}
// 入队列
Queue.prototype.push = function (item) {
this.queue.push(item);
};
// 出队列
Queue.prototype.pop = function () {
if (this.queue.length === 0) {
return null;
}
return this.queue.shift();
};
// 返回队首元素
Queue.prototype.peek = function () {
return this.queue[0];
};
// 队列是否为空
Queue.prototype.isEmpty = function () {
return this.queue.length === 0;
};
return Queue;
}());
exports["default"] = Queue;