pqueue

package module
v0.0.0-...-dacfa44 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2021 License: MIT Imports: 2 Imported by: 0

README

Pqueue

A thread safe Priority Queue implementation using container/heap

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item struct {
	Body  string // data
	Score int    // priority
}

func MakeItem

func MakeItem(body string, score int) *Item

type PriorityQueue

type PriorityQueue struct {
	List   []*Item
	Cursor int // represents length of the PriorityQueue
}

func (*PriorityQueue) Len

func (pq *PriorityQueue) Len() int

func (*PriorityQueue) Less

func (pq *PriorityQueue) Less(i, j int) bool

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x interface{})

func (*PriorityQueue) Swap

func (pq *PriorityQueue) Swap(i, j int)

type QMan

type QMan struct {
	Pq *PriorityQueue
	// contains filtered or unexported fields
}

func InitQ

func InitQ(length int) *QMan

func (*QMan) Qpop

func (fm *QMan) Qpop() *Item

func (*QMan) Qpush

func (fm *QMan) Qpush(c *Item) (err error)

func (*QMan) Qremove

func (fm *QMan) Qremove(i int) *Item

func (*QMan) UpdatePriority

func (fm *QMan) UpdatePriority(item *Item, newScore int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL