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.
Click to show internal directories.
Click to hide internal directories.