refactor: use internal method and remove toArray() method

This commit is contained in:
nuomi1
2023-01-11 23:54:04 +08:00
parent 99f1494939
commit ac7d26c131
3 changed files with 12 additions and 24 deletions

View File

@ -29,8 +29,9 @@ class ArrayStack {
}
/* */
@discardableResult
func pop() -> Int {
if stack.isEmpty {
if isEmpty() {
fatalError("栈为空")
}
return stack.removeLast()
@ -38,7 +39,7 @@ class ArrayStack {
/* 访 */
func peek() -> Int {
if stack.isEmpty {
if isEmpty() {
fatalError("栈为空")
}
return stack.last!