Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer[T any] struct { // contains filtered or unexported fields }
Buffer is a non-thread-safe ring (circular) buffer.
Notes: - Capacity is the maximum number of elements it can hold. - Internally it keeps one slot empty to distinguish full vs empty. - This is intended as a low-level primitive; add locking externally if needed.
func (*Buffer[T]) Drain ¶ added in v0.5.0
func (b *Buffer[T]) Drain() []T
Drain returns all elements as a slice and resets the buffer.
func (*Buffer[T]) Peek ¶ added in v0.5.0
Peek returns the next element without removing it. ok is false if the buffer is empty.
type ByteBuffer ¶
type ByteBuffer struct {
// contains filtered or unexported fields
}
ByteBuffer is a ring buffer specialized for bytes.
Semantics match Buffer[T]: it keeps one slot empty internally.
func NewBytes ¶
func NewBytes(capacity int) *ByteBuffer
NewBytes creates a new ByteBuffer with the given capacity.
func (*ByteBuffer) Cap ¶
func (b *ByteBuffer) Cap() int
func (*ByteBuffer) Len ¶
func (b *ByteBuffer) Len() int
func (*ByteBuffer) Read ¶
func (b *ByteBuffer) Read(p []byte) int
Read reads up to len(p) bytes and returns the number of bytes read.
func (*ByteBuffer) Reset ¶
func (b *ByteBuffer) Reset()
func (*ByteBuffer) Space ¶
func (b *ByteBuffer) Space() int
func (*ByteBuffer) Write ¶
func (b *ByteBuffer) Write(p []byte) int
Write writes as many bytes as possible and returns the number of bytes written.