Skip to content

twharmon/queues

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Queues

Thread-safe, generic queues for Go.

codecov

Documentation

For full documentation see pkg.go.dev.

Install

go get github.com/twharmon/queues

Usage

package main

import (
	"fmt"

	"github.com/twharmon/queues"
)

func main() {
	// Create a new queue of ints
	q := queues.New[int]()

	// Enqueue some values
	q.Enqueue(1, 2, 3)

	// Peek at the head
	q.Peek() // 1

	// Dequeue a value
	q.Dequeue() // 1

	// Get length of the queue
	q.Len() // 2

	// Get an ordered slice of the values in the queue
	q.Slice() // [2, 3]

	// Clear the queue
	q.Clear()
}

Contribute

Make a pull request.

Benchmarks

goos: darwin
goarch: arm64
pkg: github.com/twharmon/queues
BenchmarkEnqueue/enqueue-10         	   68956	     16422 ns/op	   25256 B/op	      13 allocs/op
BenchmarkEnqueue/enqueue_dequeue-10 	   39046	     30208 ns/op	   17072 B/op	      23 allocs/op

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages