ringlog

package
v1.104.5 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: BSD-3-Clause Imports: 1 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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