ring

package
v0.0.0-...-f9fa47e Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package ring provides an implementation of a ring buffer containing strings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

Buffer represents a ring buffer. If the buffer is full, the last item in the buffer is replaced with the new item. Can only add entries to the buffer but never remove them.

func New

func New(size int) Buffer

New returns a new RingBuffer.

func (*Buffer) Add

func (rb *Buffer) Add(entry string)

Add adds a new entry to the buffer.

func (*Buffer) Len

func (rb *Buffer) Len() int

Len returns the length of the buffer (number of entries filled).

func (*Buffer) ReadAll

func (rb *Buffer) ReadAll() []string

ReadAll returns a slice of strings with all the elements in the buffer

Jump to

Keyboard shortcuts

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