Skip to content

About

simple thread-free ringbuffer implement by golang

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

27 Commits

Folders and files

Repository files navigation

License: MIT 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

About

simple thread-free ringbuffer implement by golang

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages