2022-11-28 17:10:22 +00:00
|
|
|
// File: queue.go
|
|
|
|
// Created Time: 2022-11-29
|
|
|
|
// Author: Reanon (793584285@qq.com)
|
|
|
|
|
|
|
|
package chapter_stack_and_queue
|
|
|
|
|
|
|
|
type Queue interface {
|
|
|
|
// Offer 元素入队
|
2022-11-29 02:42:09 +00:00
|
|
|
Offer(num any)
|
2022-11-28 17:10:22 +00:00
|
|
|
// Peek 访问首元素
|
2022-11-29 02:42:09 +00:00
|
|
|
Peek() any
|
2022-11-28 17:10:22 +00:00
|
|
|
// Poll 元素出队
|
2022-11-29 02:42:09 +00:00
|
|
|
Poll() any
|
2022-11-28 17:10:22 +00:00
|
|
|
// Size 获取队列长度
|
|
|
|
Size() int
|
|
|
|
// IsEmpty 队列是否为空
|
|
|
|
IsEmpty() bool
|
2022-11-29 02:42:09 +00:00
|
|
|
// toString 队列输出为字符串
|
|
|
|
toString() string
|
2022-11-28 17:10:22 +00:00
|
|
|
}
|