pq

package
v1.14.4 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2022 License: MIT Imports: 1 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PQItem

type PQItem struct {
	Value    interface{}
	Priority int64
	Index    int
}

PQItem defines a node for a priority queue (max-heap)

type PriorityQueue

type PriorityQueue []*PQItem

Priority queue is based on a regular array

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

Len returns the length of a priority queue

func (PriorityQueue) Less

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

Less defines the order between two priority queue entries

func (*PriorityQueue) Pop

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

Pop pulls the top (max priority) element from a priority queue. Complexity: O(1)

func (*PriorityQueue) Push

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

Push inserts an element to a priority queue. Complexity: O(logN)

func (PriorityQueue) Swap

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

Swap is used for swapping two priority queue elements on sorting

Jump to

Keyboard shortcuts

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