Skip to content

Latest commit

 

History

History
31 lines (24 loc) · 971 Bytes

README.md

File metadata and controls

31 lines (24 loc) · 971 Bytes

priority-queue

priority queue implementation in golang

PkgGoDev Build Status Coverage Status

Description

A generic priority queue implementation over a max heap.

Usage

package main

import (
    "fmt"
    "github.com/dannoane/priority-queue"
)

func main() {
    pq := priorityqueue.NewPriorityQueue()
    pq.Push(&priorityqueue.Element{Value: 1, Priority: 200})
    pq.Push(&priorityqueue.Element{Value: 2, Priority: 100})
    pq.Push(&priorityqueue.Element{Value: 3, Priority: 300})

    for !pq.IsEmpty() {
        fmt.Println(pq.Pop().Value)
    }
}