Skip to content
/ go-pq Public

Generic priority queue implementation for Go.

License

Notifications You must be signed in to change notification settings

kk-min/go-pq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Priority Queue

Generic priority queue implementation for Go.

Usage

type CustomItem struct{
	Key string
	Val int
}

// Create a PriorityQueue of type CustomItem by passing in a "less" comparator function to CreatePQ:
q := pq.CreatePQ[CustomItem](func(a, b CustomItem) bool { return a.Val < b.Val })

// Put items in the Priority Queue:
q.Put(CustomItem{"a", 5})
q.Put(CustomItem{"b", 1})

// Peek the head of the queue:
q.Peek() // CustomItem{"b", 1}

// Get (Dequeue) the head of the queue:
q.Get() // CustomItem{"b", 1}

About

Generic priority queue implementation for Go.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages