datastructures

package
v0.0.0-...-45e99ae Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MaxHeap

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

MaxHeap represents a max heap

func BuildMaxHeapFromArray

func BuildMaxHeapFromArray(input []int) *MaxHeap

BuildMaxHeapFromArray creates a new max heap from an array of values

func NewMaxHeap

func NewMaxHeap() *MaxHeap

NewMaxHeap creates a new max heap

func (*MaxHeap) Insert

func (heap *MaxHeap) Insert(val int)

Insert inserts a value int the heap

func (*MaxHeap) Max

func (heap *MaxHeap) Max() (int, error)

Max returns the max element in the heap

func (*MaxHeap) Pop

func (heap *MaxHeap) Pop() (int, error)

Pop removes the least element in the heap

func (MaxHeap) Size

func (heap MaxHeap) Size() int

Size represents the current size of the heap

type MinHeap

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

MinHeap is the data structure for a min heap

func BuildMinHeapFromArray

func BuildMinHeapFromArray(input []int) *MinHeap

BuildMinHeapFromArray creates a new min heap from a slice of integers

func NewMinHeap

func NewMinHeap() *MinHeap

NewMinHeap creates a new min heap

func (*MinHeap) Insert

func (heap *MinHeap) Insert(val int)

Insert inserts a value in the min heap

func (*MinHeap) Min

func (heap *MinHeap) Min() (int, error)

Min returns the min element in the heap

func (*MinHeap) Pop

func (heap *MinHeap) Pop() (int, error)

Pop returns the min element in the heap and removes it

func (MinHeap) Size

func (heap MinHeap) Size() int

Size returns the size of a mean heap

Jump to

Keyboard shortcuts

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