mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-06 22:34:18 +08:00
Update the structure of the chapter
of binary tree.
This commit is contained in:
@ -41,13 +41,6 @@ class ArrayStack {
|
||||
return this.stack[this.stack.length - 1];
|
||||
}
|
||||
|
||||
/* 访问索引 index 处元素 */
|
||||
get(index) {
|
||||
if (index >= this.size)
|
||||
throw new Error("索引越界");
|
||||
return this.stack[index];
|
||||
}
|
||||
|
||||
/* 返回 Array */
|
||||
toArray() {
|
||||
return this.stack;
|
||||
@ -73,10 +66,6 @@ console.log(stack.toArray());
|
||||
const top = stack.top();
|
||||
console.log("栈顶元素 top = " + top);
|
||||
|
||||
/* 访问索引 index 处元素 */
|
||||
const num = stack.get(3);
|
||||
console.log("栈索引 3 处的元素为 num = " + num);
|
||||
|
||||
/* 元素出栈 */
|
||||
const pop = stack.pop();
|
||||
console.log("出栈元素 pop = " + pop + ",出栈后 stack = ");
|
||||
|
Reference in New Issue
Block a user