package
module
Version:
v0.2.0
Opens a new window with list of versions in this module.
Published: May 8, 2026
License: MIT
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
type Ring[T any] struct {
}
Ring 是一个固定容量的环形缓冲区(循环队列)
当缓冲区满时,新元素会覆盖最旧的元素
该实现不是并发安全的,如需并发使用请添加互斥锁
Items 返回一个迭代器,按从旧到新的顺序遍历所有元素
每个元素会返回其索引(0-based)和值
func (r *Ring[T]) Push(item T)
Push 添加一个元素到缓冲区
如果缓冲区已满,会覆盖最旧的元素
Source Files
¶
Click to show internal directories.
Click to hide internal directories.