ringbuffer

package module
v0.0.0-...-a79150e Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2021 License: MIT Imports: 1 Imported by: 0

README

Build Status

Simple ringbuffer

Simple thread-free ringbuffer implement by golang

install


go get github.com/Noahnut/ringbuffer
Ringbuffer struct
type ringbuff struct {
	ringbufferArray []interface{}
	size            int
	front           int
	rear            int
	len             int
	mux             *sync.RWMutex
}
Enqueu

add element to the ringbuffer if ringbuffer is full return false

func (this *ringbuff) Enqueue(value interface{}) bool
Dequeue

delete element from the ringbuffer if ringbuffer is empty return false

func (this *ringbuff) Dequeue() bool
GetFront

get the top element on the queue if the queue is empty return nil

func (this *ringbuff) GetFront() interface{}
GetRear

get the last element on the queue if the queue is empty return nil

func (this *ringbuff) GetRear() interface{}
IsEmpty

check the ringbuffer is empty or not if is empty return true

func (this *ringbuff) IsEmpty() bool
IsFull

check the ringbuffer is full or not if is empty return true

func (this *ringbuff) IsFull() bool

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RingBufferConstruct

func RingBufferConstruct(size int) ringbuff

Types

This section is empty.

Jump to

Keyboard shortcuts

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