Discover Packages
github.com/rovergulf/utils
datastructures
minheap
package
Version:
v1.14.4
Opens a new window with list of versions in this module.
Published: Feb 24, 2022
License: MIT
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
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.
Opens a new window with list of known importers.
Documentation
Documentation
¶
Priority queue is based on a regular array
Len returns the length of a priority queue
Less defines the order between two priority queue entries
func (h *MinHeap ) Peek() interface{}
Peek returns the top element (min priority)
func (h *MinHeap ) Pop() interface{}
Pop pulls the top (max priority) element from a priority queue. Complexity: O(1)
func (h *MinHeap ) Push(x interface{})
Push inserts an element to a priority queue. Complexity: O(logN)
Swap is used for swapping two priority queue elements on sorting
Update allows to change a priority queue item's value and priority. Complexity: O(logN)
type PQItem struct {
Value interface{}
Priority int64
Index int
}
PQItem defines a node for a priority queue
Source Files
¶
Click to show internal directories.
Click to hide internal directories.