container

package
v0.3.2 Latest Latest
Warning

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

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

Documentation

Overview

Package ring, Simple RingBuffer pacakge from https://github.com/sahmad98/go-ringbuffer/blob/master/ring_buffer.go

Ringbuffer is non blocking for readers and writers, writers will overwrite older data in a circular fashion. Readers will read from the current position and update it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RingBuffer

type RingBuffer struct {
	Size      int32 // Size of the Ringbuffer
	Container []any // Array container of objects
	Reader    int32 // Reader position
	Writer    int32 // Writer Position
}

RingBuffer Structure

func NewRingBuffer

func NewRingBuffer(size int32) *RingBuffer

Create a new RingBuffer of initial size "size" Returns a pointer to the new RingBuffer

func (*RingBuffer) Latest

func (r *RingBuffer) Latest() any

Returns the latest element in the RingBuffer

func (*RingBuffer) Oldest

func (r *RingBuffer) Oldest() any

Returns the oldest element in RingBuffer

func (*RingBuffer) Overwrite

func (r *RingBuffer) Overwrite(v any)

Overwrites the latest data in RingBuffer

func (*RingBuffer) Read

func (r *RingBuffer) Read() any

Read single object from the RingBuffer

func (*RingBuffer) Write

func (r *RingBuffer) Write(v any)

Write object into the RingBuffer

Jump to

Keyboard shortcuts

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