mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-07 23:04:55 +08:00
Update the structure of the chapter
of binary tree.
This commit is contained in:
@ -45,13 +45,6 @@ class ArrayStack {
|
||||
return stack.get(size() - 1);
|
||||
}
|
||||
|
||||
/* 访问索引 index 处元素 */
|
||||
public int get(int index) {
|
||||
if (index >= size())
|
||||
throw new IndexOutOfBoundsException();
|
||||
return stack.get(index);
|
||||
}
|
||||
|
||||
/* 将 List 转化为 Array 并返回 */
|
||||
public Object[] toArray() {
|
||||
return stack.toArray();
|
||||
@ -75,10 +68,6 @@ public class array_stack {
|
||||
int peek = stack.peek();
|
||||
System.out.println("栈顶元素 peek = " + peek);
|
||||
|
||||
/* 访问索引 index 处元素 */
|
||||
int num = stack.get(3);
|
||||
System.out.println("栈索引 3 处的元素为 num = " + num);
|
||||
|
||||
/* 元素出栈 */
|
||||
int pop = stack.pop();
|
||||
System.out.println("出栈元素 pop = " + pop + ",出栈后 stack = " + Arrays.toString(stack.toArray()));
|
||||
|
Reference in New Issue
Block a user