impl

package
v2.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package impl 实现环形缓冲区的数组存储版本

Package impl 定义环形缓冲区的实现接口

Package impl 实现环形缓冲区的链表存储版本

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer[T any] interface {
	Push(item T)        // 添加单个元素
	PushAll(items []T)  // 批量添加元素
	GetAll() []T        // 获取所有元素
	GetLast(n int) []T  // 获取最后n个元素
	Clear()             // 清空缓冲区
	Len() int           // 当前元素数量
	Cap() int           // 缓冲区容量
	IsFull() bool       // 是否已满
	IsEmpty() bool      // 是否为空
	Iterator() <-chan T // 创建元素迭代器
}

Buffer 定义环形缓冲区公开接口

func NewArrayBuffer

func NewArrayBuffer[T any](size int) Buffer[T]

NewArrayBuffer 创建数组实现的环形缓冲区

func NewLinkedListBuffer

func NewLinkedListBuffer[T any](size int) Buffer[T]

NewLinkedListBuffer 创建链表实现的环形缓冲区

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL