项目作者: anjulapaulus

项目描述 :
A simple and smallest binary heap priority queue in golang
高级语言: Go
项目地址: git://github.com/anjulapaulus/tinyqueue.git
创建时间: 2020-04-10T17:53:23Z
项目社区:https://github.com/anjulapaulus/tinyqueue

开源协议:

下载


Build Status
codecov
HitCount

tinyqueue

A simple and smallest binary heap priority queue in golang.

Installation

  1. go get -u github.com/anjulapaulus/tinyqueue

Acknowledgement

The current implementation is inspired on the javascript library tinyqueue by Vladimir Agafonkin.

Implementation

````
package main

import queue “github.com/anjulapaulus/tinyqueue”

type Val int64

func (a Val) Compare (b queue.Item) bool{
return a <= b.(Val)
}

func main(){
q:= queue.Queue{} //Initialize Queue

  1. q.Push(Val(2)) //Insert Items to queue
  2. q.Push(Val(5))
  3. q.Push(Val(10))
  4. array := q.All() //returns array of elemeents in queue
  5. q.Peek() //returns the top item without removal
  6. q.Len() //length of queue
  7. q.Pop() //removes the top item and displays

}