Simple thread-free ringbuffer implement by golang
go get github.com/Noahnut/ringbuffer
type ringbuff struct {
ringbufferArray []interface{}
size int
front int
rear int
len int
mux *sync.RWMutex
}
add element to the ringbuffer if ringbuffer is full return false
func (this *ringbuff) Enqueue(value interface{}) bool
delete element from the ringbuffer if ringbuffer is empty return false
func (this *ringbuff) Dequeue() bool
get the top element on the queue if the queue is empty return nil
func (this *ringbuff) GetFront() interface{}
get the last element on the queue if the queue is empty return nil
func (this *ringbuff) GetRear() interface{}
check the ringbuffer is empty or not if is empty return true
func (this *ringbuff) IsEmpty() bool
check the ringbuffer is full or not if is empty return true
func (this *ringbuff) IsFull() bool