mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-07 06:44:57 +08:00
Update the structure of the chapter
of binary tree.
This commit is contained in:
@ -56,13 +56,6 @@ class ArrayQueue {
|
||||
return this.#queue[this.#front];
|
||||
}
|
||||
|
||||
/* 访问指定索引元素 */
|
||||
get(index) {
|
||||
if (index >= this.size)
|
||||
throw new Error("索引越界");
|
||||
return this.#queue[(this.#front + index) % this.capacity];
|
||||
}
|
||||
|
||||
/* 返回 Array */
|
||||
toArray() {
|
||||
const siz = this.size;
|
||||
@ -95,10 +88,6 @@ console.log(queue.toArray());
|
||||
const peek = queue.peek();
|
||||
console.log("队首元素 peek = " + peek);
|
||||
|
||||
/* 访问指定索引元素 */
|
||||
const num = queue.get(2);
|
||||
console.log("队列第 3 个元素为 num = " + num);
|
||||
|
||||
/* 元素出队 */
|
||||
const poll = queue.poll();
|
||||
console.log("出队元素 poll = " + poll + ",出队后 queue = ");
|
||||
|
Reference in New Issue
Block a user