heap

package
v1.8.11 Latest Latest
Warning

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

Go to latest
Published: May 26, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdjustDown

func AdjustDown[T cmp.CompareKey[V], V constraints.Ordered](heap []T, i int)

与Down一致,不同的写法

func AdjustUp

func AdjustUp[T cmp.CompareKey[V], V constraints.Ordered](heap []T, i int)

与Up一致,不同的写法

func Down

func Down[T cmp.CompareKey[V], V constraints.Ordered](heap []T, i0, n int) bool

func Fix

func Fix[T cmp.CompareKey[V], V constraints.Ordered](heap []T, i int)

func Init

func Init[T cmp.CompareKey[V], V constraints.Ordered](heap []T)

func Up

func Up[T cmp.CompareKey[V], V constraints.Ordered](heap []T, j int)

Types

type Heap

type Heap[T cmp.CompareKey[V], V constraints.Ordered] []T

func New

func New[T cmp.CompareKey[V], V constraints.Ordered](l int) Heap[T, V]

func NewFromArray

func NewFromArray[T cmp.CompareKey[V], V constraints.Ordered](arr []T) Heap[T, V]

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

func (heap Heap[T, V]) First() (T, bool)

func (Heap[T, V]) Init

func (h Heap[T, V]) Init()

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

func (heap Heap[T, V]) Last() (T, bool)

func (*Heap[T, V]) Pop

func (heap *Heap[T, V]) Pop() (T, bool)

func (*Heap[T, V]) Push

func (heap *Heap[T, V]) Push(x T)

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

func (*Heap[T, V]) Put

func (heap *Heap[T, V]) Put(val T)

不会改变预设堆的大小

func (*Heap[T, V]) Remove

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

Jump to

Keyboard shortcuts

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