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 }
A RingBuffer is a ring buffer. It acts as a heap that doesn't cause any allocations.
func (*RingBuffer[T]) Empty ¶
func (r *RingBuffer[T]) Empty() bool
Empty says if the ring buffer is empty.
func (*RingBuffer[T]) Init ¶
func (r *RingBuffer[T]) Init(size int)
Init preallocs a buffer with a certain size.
func (*RingBuffer[T]) Len ¶
func (r *RingBuffer[T]) Len() int
Len returns the number of elements in the ring buffer.
func (*RingBuffer[T]) PopFront ¶
func (r *RingBuffer[T]) PopFront() T
PopFront returns the next element. It must not be called when the buffer is empty, that means that callers might need to check if there are elements in the buffer first.
func (*RingBuffer[T]) PushBack ¶
func (r *RingBuffer[T]) PushBack(t T)
PushBack adds a new element. If the ring buffer is full, its capacity is increased first.
Click to show internal directories.
Click to hide internal directories.