heap

package
v1.10.8 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdjustDown

func AdjustDown[T any](heap []T, i int, less cmp.LessFunc[T])

与Down一致,不同的写法

func AdjustUp

func AdjustUp[T any](heap []T, i int, less cmp.LessFunc[T])

与Up一致,不同的写法

func Down

func Down[T any](heap []T, i0, n int, less cmp.LessFunc[T]) bool

func Fix

func Fix[T any](heap []T, i int, less cmp.LessFunc[T])

func HeapInit

func HeapInit[T any](heap []T, less cmp.LessFunc[T])

func Up

func Up[T any](heap []T, j int, less cmp.LessFunc[T])

Types

type Heap

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

func New

func New[T any](l int, less cmp.LessFunc[T]) *Heap[T]

func NewFromArray

func NewFromArray[T any](arr []T, less cmp.LessFunc[T]) *Heap[T]

func (*Heap[T]) First added in v1.8.2

func (h *Heap[T]) First() (T, bool)

func (*Heap[T]) Init

func (h *Heap[T]) Init()

func (Heap[T]) Last added in v1.8.2

func (h Heap[T]) Last() (T, bool)

func (*Heap[T]) Pop

func (h *Heap[T]) Pop() (T, bool)

func (*Heap[T]) Push

func (h *Heap[T]) Push(x T)

当达到堆预设大小时会增加堆的大小

func (*Heap[T]) Put

func (h *Heap[T]) Put(val T)

不会改变预设堆的大小

func (*Heap[T]) Remove

func (h *Heap[T]) Remove(i int) (T, bool)

Jump to

Keyboard shortcuts

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