heap

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CHeap

type CHeap[P Number, T comparable] Heap[P, T]

A subtype of Heap where the content is comparable,

ie one node can have equal content to another

func (*CHeap[P, T]) ExtractMax

func (ch *CHeap[P, T]) ExtractMax()

func (*CHeap[P, T]) GetMax

func (ch *CHeap[P, T]) GetMax()

func (*CHeap[P, T]) GetNodes

func (ch *CHeap[P, T]) GetNodes(content T) ([]*Node[P, T], error)

asynchronously queries every node to get the list of nodes that contain T

func (*CHeap[P, T]) IncreasePriority

func (ch *CHeap[P, T]) IncreasePriority(n *Node[P, T], newPriority P)

func (*CHeap[P, T]) Insert

func (ch *CHeap[P, T]) Insert(priority P, element T)

func (*CHeap[P, T]) InsertNode

func (ch *CHeap[P, T]) InsertNode(n *Node[P, T])

func (*CHeap[P, T]) Merge

func (ch *CHeap[P, T]) Merge(ch2 *CHeap[P, T])

type DegreeArray

type DegreeArray[P Number, T any] []*Node[P, T]

A type of NodeList such that at index i lies a tree of degree i

type Heap

type Heap[P Number, T any] struct {
	// contains filtered or unexported fields
}

func (*Heap[P, T]) ExtractMax

func (h *Heap[P, T]) ExtractMax() (P, T)

Deletes the max, and returns it

func (*Heap[P, T]) GetMax

func (h *Heap[P, T]) GetMax() *Node[P, T]

returns the stored Node with max value.

func (*Heap[P, T]) IncreasePriority

func (h *Heap[P, T]) IncreasePriority(n *Node[P, T], newPriority P)

Increases the priority of a node If the node is would get a larger priority than its parent, then adds it as a new root

func (*Heap[P, T]) Insert

func (h *Heap[P, T]) Insert(priority P, element T)

func (*Heap[P, T]) InsertNode

func (h *Heap[P, T]) InsertNode(n ...*Node[P, T])

InsertNodes and updates maximum

func (*Heap[P, T]) Merge

func (h *Heap[P, T]) Merge(h2 *Heap[P, T])

Merges h2 into h1 before emptying h2

type Node

type Node[P Number, T any] struct {
	// contains filtered or unexported fields
}

A Node stores a value and a priority such that getting the minimal priority of a Heap is easy

func (*Node[P, T]) Degree

func (n *Node[P, T]) Degree() int

func (*Node[P, T]) GetValue

func (n *Node[P, T]) GetValue() T

type Number

type Number interface {
	constraints.Integer | constraints.Float
}

Jump to

Keyboard shortcuts

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