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: 0

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