Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Queue ¶
type Queue interface {
// Enq Go 暂时还不支持泛型 只能用 interface 类型接收 入队
Enq(e byte)
// Deq 出队
Deq() byte
// IsEmpty 是否空
IsEmpty() bool
// IsFull 是否满
IsFull() bool
}
Queue 先定义队列的需要实现的规范 最主要的就是出队 入队 出入队的情况下 还有 是否满 是否空
type RingQueue ¶
type RingQueue struct {
// 定义真正的存储结构 使用一个数组来存储 这个主要是在 函数传递的时候 函数压栈 会创建数组的副本 如果仅仅是可读没有任何问题
// 数组和切片的区别: 切片:引用数据类型 数组:值类型
// 我们直接使用数组 使用字节存储
Arr [4]byte
// 读写的位置, 操作系统就是可读 可写;
// 代表可读的索引
Front int
// 代表可写的索引
Rear int
// 定义上一动作是出队 还是 入队
// 优化 约定 front 在 rear 下一个位置 为 满 这种方式其实很容易 理解
Op bool
}
RingQueue 环形队列 可固定长度 可默认长度 go的构造方法:
Click to show internal directories.
Click to hide internal directories.