package main
//使用一个结构体管理队列
type CircleQueue struct {
maxSize int
array [5]int //数组=>模拟队列
head int //指向队列首 0
tail int //指向队队尾 0
}
//
func (this *CircleQueue)Push(val int) (err error) {
return nil
}
func (this *CircleQueue)Pop(val int) (err error) {
return nil
}
func (this *CircleQueue)IsFull(val int) (res bool) {
res = (this.tail+1)%this.maxSize == this.head
return
}
func (this *CircleQueue)IsEmpty(val int) (res bool) {
res = this.tail == this.head
return
}
func main() {
}
Go数据结构--环形队列
最新推荐文章于 2024-06-17 00:00:00 发布