2022-11-28 17:09:12 +00:00
|
|
|
// File: stack.go
|
|
|
|
// Created Time: 2022-11-26
|
|
|
|
// Author: Reanon (793584285@qq.com)
|
|
|
|
|
|
|
|
package chapter_stack_and_queue
|
|
|
|
|
|
|
|
type Stack interface {
|
|
|
|
// Push 元素入栈
|
|
|
|
Push(num int)
|
|
|
|
// Peek 访问栈顶元素
|
2022-11-29 02:42:09 +00:00
|
|
|
Peek() any
|
2022-11-28 17:09:12 +00:00
|
|
|
// Pop 元素出栈
|
2022-11-29 02:42:09 +00:00
|
|
|
Pop() any
|
2022-11-28 17:09:12 +00:00
|
|
|
// Size 栈的长度
|
|
|
|
Size() int
|
|
|
|
// IsEmpty 栈是否为空
|
|
|
|
IsEmpty() bool
|
2022-11-29 02:42:09 +00:00
|
|
|
// toString 栈输出为字符串
|
|
|
|
toString() string
|
2022-11-28 17:09:12 +00:00
|
|
|
}
|