ringbuffer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RingBuffer

type RingBuffer[T any] struct {
	// contains filtered or unexported fields
}

RingBuffer is a generic circular buffer that stores items of any type.

func New

func New[T any](size int) *RingBuffer[T]

New creates a new ring buffer with the specified capacity.

func (*RingBuffer[T]) Cap

func (r *RingBuffer[T]) Cap() int

Cap returns the capacity of the ring buffer.

func (*RingBuffer[T]) GetAll

func (r *RingBuffer[T]) GetAll() []T

GetAll returns all items in the buffer, oldest first.

func (*RingBuffer[T]) Len

func (r *RingBuffer[T]) Len() int

Len returns the number of items currently in the buffer.

func (*RingBuffer[T]) Push

func (r *RingBuffer[T]) Push(item T)

Push adds an item to the ring buffer, overwriting the oldest if full.

Jump to

Keyboard shortcuts

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