# priority_queue **Repository Path**: OnMyOa/priority_queue ## Basic Information - **Project Name**: priority_queue - **Description**: No description available - **Primary Language**: Go - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-01-10 - **Last Updated**: 2024-11-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 非线程安全的优先队列(golang标准库中的heap是小根堆) ~~~ go package main import ( "fmt" "github.com/gansidui/priority_queue" ) type Node struct { priority int value int } func (this *Node) Less(other interface{}) bool { return this.priority < other.(*Node).priority } func main() { q := priority_queue.New() q.Push(&Node{priority: 8, value: 1}) q.Push(&Node{priority: 7, value: 2}) q.Push(&Node{priority: 9, value: 3}) x := q.Top().(*Node) fmt.Println(x.priority, x.value) for q.Len() > 0 { x = q.Pop().(*Node) fmt.Println(x.priority, x.value) } // output: // 7 2 // 7 2 // 8 1 // 9 3 } ~~~ ##LICENSE MIT