Mottl / circularqueue

Go package circularqueue implements a thread-safe circular queue

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Thread-safe circular queue for Go

GoDoc

Installation

go get github.com/Mottl/circularqueue

Example

package main
  
import (
    "fmt"
    "github.com/Mottl/circularqueue"
)

func main() {
    queue := circularqueue.NewQueue(64)
    queue.Push(100)
    queue.Push(101)
    queue.Push(102)
    queue.Push(103)
    queue.PopAt(1)     // 101, nil
    queue.Pop()        // 103, nil
    fmt.Println(queue) // Queue (len=2, cap=64) [ 100, 102 ]
}

License

Use of this package is governed by MIT license that can be found in the LICENSE file.

About

Go package circularqueue implements a thread-safe circular queue

License:MIT License


Languages

Language:Go 100.0%