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 NewRingBuffer ¶
func NewRingBuffer[T any](capacity int, metrics Metrics) *RingBuffer[T]
NewRingBuffer returns a new ring buffer with the given capacity.
Capacity must be in the range [1, MaxInt/2].
func (*RingBuffer[T]) Pop ¶
func (rb *RingBuffer[T]) Pop() (elem T, ok bool)
Pop removes and returns the oldest element in the buffer if the buffer isn't empty.
func (*RingBuffer[T]) Push ¶
func (rb *RingBuffer[T]) Push(elem T)
Push adds an element to the buffer. If the buffer is full, it overwrites the oldest element.
Click to show internal directories.
Click to hide internal directories.