环形队列
环形队列的优点
接口
package ring_queue
type RingQueueInterface interface {
// 获取队列中元素个数
Len() int
// 获取队首元素
Head() interface{}
// 获取队尾元素
Tail() interface{}
// 从队尾添加元素
Insert(x interface{}) bool
// 移除队首元素
LPop() bool
// 队列已满
IsFull() bool
// 队列为空
Empty() bool
}
type RingDequeInterface interface {
// 移除队尾元素
Pop() bool
// 从队首添加元素
LInsert(x interface{}) bool
RingQueueInterface
}环形队列(阻塞版,环形缓冲器)实现
阻塞版环形队列 PK channel
有锁版环形队列 PK 无锁版环形队列
无锁版环形队列对并发的支持(验证性实验)
环形队列(阻塞版)小结
环形队列(非阻塞版)实现 TODO: 待实现以及数据验证
参考
最后更新于