buffer

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GrowingRing

type GrowingRing[T any] struct {
	// contains filtered or unexported fields
}

func NewGrowingRing

func NewGrowingRing[T any](capacity int64) *GrowingRing[T]

NewGrowingRing creates a growing ring buffer with the given capacity (rounded up to nearest power of 2).

func (*GrowingRing[T]) Len

func (rb *GrowingRing[T]) Len() int64

Len returns the number of items in the buffer.

func (*GrowingRing[T]) Pop

func (rb *GrowingRing[T]) Pop() (T, bool)

Pop removes and returns the first item, or false if empty.

func (*GrowingRing[T]) PopN

func (rb *GrowingRing[T]) PopN(n int64) ([]T, bool)

PopN removes up to n items and returns them, or false if empty.

func (*GrowingRing[T]) Push

func (rb *GrowingRing[T]) Push(item T)

Push appends an item to the buffer, growing if necessary.

Jump to

Keyboard shortcuts

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