ringbuffer

package
v0.0.0-...-4aa2a59 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 2 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
}

func New

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

New is a fixed-size ring/circle buffer of values.

func (*RingBuffer[T]) Capacity

func (b *RingBuffer[T]) Capacity() int

Capacity of the buffer

func (*RingBuffer[T]) Count

func (b *RingBuffer[T]) Count() int

Count the number of records in the buffer

func (*RingBuffer[T]) Peek

func (b *RingBuffer[T]) Peek() (bool, T)

Peek an item from the ring buffer

func (*RingBuffer[T]) Pop

func (b *RingBuffer[T]) Pop() (bool, T)

Pop an item from the ring buffer

func (*RingBuffer[T]) Push

func (b *RingBuffer[T]) Push(item T) error

Push an item into the ring-buffer. Returns an error if we overflow the buffer

Jump to

Keyboard shortcuts

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