/gcircularqueue

Circular Queue in Golang

Primary LanguageGoMIT LicenseMIT

gcircularqueue is Circular Queue in Golang

Install

go get github.com/Focinfi/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