API reference

Raw Markdown View this page on GitHub

API reference

import "example.com/ringbuf"

New

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

New returns an empty buffer for size values. size must be a power of 2.

Push

func (b *Buffer[T]) Push(v T) bool

Push appends v and reports whether the buffer had room for it.

Pop

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

Pop removes the oldest value and reports whether there was one.