gcircularqueue is Circular Queue in Golang
Install
go get github.com/vadimipatov/gcircularqueue
Usage
This package is a typical circular with interfaces as following:
New
Normal queue
queue := gcircularqueue.NewCircularQueue(size int)
Thread-safe queue via sync.RWMutex
queue := gcircularqueue.NewCircularQueueThreadSafe(size int)
IsEmpty/IsFull
isEmpty := queue.IsEmpty()
isFull := queue.IsFull()
Push
queue.Push("kitty")
// note: it will panic if pushing a thing into a full queue
Shift
element := queue.Shift()
// note: `element will be nil when shifting from a empty queue
TODO
- Update this README
- Add methods Len and Elements to the threadsafe implementation
- Update tests