This commit is contained in:
krahets
2023-09-13 03:40:35 +08:00
parent 2f051b6ff8
commit 821898534f
6 changed files with 28 additions and 18 deletions

View File

@@ -1660,7 +1660,7 @@ comments: true
}
/* 判断队列是否为空 */
empty() {
isEmpty() {
return this.#queSize === 0;
}
@@ -1689,7 +1689,7 @@ comments: true
/* 访问队首元素 */
peek() {
if (this.empty()) throw new Error('队列为空');
if (this.isEmpty()) throw new Error('队列为空');
return this.#nums[this.#front];
}
@@ -1730,7 +1730,7 @@ comments: true
}
/* 判断队列是否为空 */
empty(): boolean {
isEmpty(): boolean {
return this.queSize === 0;
}
@@ -1759,7 +1759,7 @@ comments: true
/* 访问队首元素 */
peek(): number {
if (this.empty()) throw new Error('队列为空');
if (this.isEmpty()) throw new Error('队列为空');
return this.nums[this.front];
}