minheap

package
v0.0.0-...-bc94fc3 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package minheap implements an integer minheap.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MinHeap

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

MinHeap provides the integer minheap functionality. It can be passed as a copy, as it works with pointers internally. It is not goroutine-safe, users must implement mutexes on their end.

func NewHeap

func NewHeap(init []int) MinHeap

NewHeap makes a new MinHeap with the initial values from `init`.

func (MinHeap) Min

func (h MinHeap) Min() int

Min returns the smallest element from a MinHeap. The time complexity is O(1).

func (MinHeap) Pop

func (h MinHeap) Pop() int

Pop pops the smallest element from a MinHeap. The time complexity is O(log n)

func (MinHeap) Push

func (h MinHeap) Push(x int)

Push pushes a new element into a MinHeap. The time complexity is O(log n)

Jump to

Keyboard shortcuts

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