heap

package
v0.0.0-...-73cdf94 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2020 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 MaxHeap

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

func HeapifyNew

func HeapifyNew(nums []int) *MaxHeap

heapify构造最大堆

func NewMaxHeap

func NewMaxHeap() *MaxHeap

func (*MaxHeap) Add

func (h *MaxHeap) Add(e int)

向堆中添加元素

func (*MaxHeap) ExtractMax

func (h *MaxHeap) ExtractMax() int

删除堆顶的元素

func (*MaxHeap) FindMax

func (h *MaxHeap) FindMax() int

func (*MaxHeap) IsEmpty

func (h *MaxHeap) IsEmpty() bool

func (*MaxHeap) Len

func (h *MaxHeap) Len() int

func (*MaxHeap) Replace

func (h *MaxHeap) Replace(e int) int

取出堆顶的元素,并替换为元素e

type MinHeap

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

最小堆

func NewMinHeap

func NewMinHeap() *MinHeap

func (*MinHeap) Add

func (h *MinHeap) Add(e int)

向最小堆中添加元素e

func (*MinHeap) ExtractMin

func (h *MinHeap) ExtractMin() int

推出堆中的最小值(堆顶元素)

func (*MinHeap) FindMin

func (h *MinHeap) FindMin() int

找到并返回堆中的最小值(堆顶元素)

func (*MinHeap) IsEmpty

func (h *MinHeap) IsEmpty() bool

func (*MinHeap) Len

func (h *MinHeap) Len() int

func (*MinHeap) Replace

func (h *MinHeap) Replace(e int) int

取出堆顶的元素,并替换为e

type PriorityQueue

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

基于最大堆实现的优先队列

func NewPriorityQueue

func NewPriorityQueue() *PriorityQueue

func (*PriorityQueue) Dequeue

func (q *PriorityQueue) Dequeue() interface{}

func (*PriorityQueue) Enqueue

func (q *PriorityQueue) Enqueue(e interface{})

func (*PriorityQueue) GetFront

func (q *PriorityQueue) GetFront() interface{}

func (*PriorityQueue) IsEmpty

func (q *PriorityQueue) IsEmpty() bool

func (*PriorityQueue) Len

func (q *PriorityQueue) Len() int

Directories

Path Synopsis
leetcode
215

Jump to

Keyboard shortcuts

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