Help us shape the future of Go! Take the 2026 Go Developer Survey

ringlog

package
v1.104.2 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package ringlog contains a limited-size concurrency-safe generic ring log.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RingLog

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

RingLog is a concurrency-safe fixed size log window containing entries of [T].

func New

func New[T any](max int) *RingLog[T]

New creates a new RingLog containing at most max items.

func (*RingLog[T]) Add

func (rb *RingLog[T]) Add(t T)

Add appends a new item to the RingLog, possibly overwriting the oldest item in the log if it is already full.

It does nothing if rb is nil.

func (*RingLog[T]) Clear

func (rb *RingLog[T]) Clear()

Clear will empty the ring log.

It does nothing if rb is nil.

func (*RingLog[T]) GetAll

func (rb *RingLog[T]) GetAll() []T

GetAll returns a copy of all the entries in the ring log in the order they were added.

It returns nil if rb is nil.

func (*RingLog[T]) Len

func (rb *RingLog[T]) Len() int

Len returns the number of elements in the ring log. Note that this value could change immediately after being returned if a concurrent caller modifies the log.

Jump to

Keyboard shortcuts

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