priorityqueue

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item struct {
	// contains filtered or unexported fields
}

An Item is something we manage in a priority queue.

type PriorityQueue

type PriorityQueue []*Item

A PriorityQueue implements heap.Interface and holds Items.

func InitPriorityQueue

func InitPriorityQueue(items []string) *PriorityQueue

InitPriorityQueue init all priority is 0

func InitPriorityQueueMap

func InitPriorityQueueMap(items map[string]int) *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)

func (*PriorityQueue) Take

func (pq *PriorityQueue) Take() *Item

func (*PriorityQueue) UpdatePriorityQueue

func (pq *PriorityQueue) UpdatePriorityQueue(value string, priority int) bool

UpdatePriorityQueue update or add an item to PQ priority can be positive or negitive

Jump to

Keyboard shortcuts

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