heap

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdjustDownForBase

func AdjustDownForBase[T any](heap []T, i int, less _interface.CompareFunc[T])

与Down一致,不同的写法

func AdjustUpForBase

func AdjustUpForBase[T any](heap []T, i int, less _interface.CompareFunc[T])

与Up一致,不同的写法

func Down

func Down[T _interface.OrderKey[V], V constraints.Ordered](heap []T, i0, n int, less _interface.CompareFunc[V]) bool

func DownForBase

func DownForBase[T any](heap []T, i0, n int, less _interface.CompareFunc[T]) bool

标准库写法

func Fix

func Fix[T _interface.OrderKey[V], V constraints.Ordered](heap []T, i int, less _interface.CompareFunc[V])

func FixForBase

func FixForBase[T any](heap []T, i int, less _interface.CompareFunc[T])

func HeapInit

func HeapInit[T _interface.OrderKey[V], V constraints.Ordered](heap []T, less _interface.CompareFunc[V])

func HeapInitForBase

func HeapInitForBase[T any](heap []T, less _interface.CompareFunc[T])

func Up

func Up[T _interface.OrderKey[V], V constraints.Ordered](heap []T, j int, less _interface.CompareFunc[V])

func UpForBase

func UpForBase[T any](heap []T, j int, less _interface.CompareFunc[T])

Types

type BaseHeap

type BaseHeap[T constraints.Ordered] []T

func NewBaseHeap

func NewBaseHeap[T constraints.Ordered](l int) BaseHeap[T]

func NewBaseHeapFromArray

func NewBaseHeapFromArray[T constraints.Ordered](arr []T, less _interface.CompareFunc[T]) BaseHeap[T]

type FixedCapBaseHeap

type FixedCapBaseHeap[T constraints.Ordered] BaseHeap[T]

func NewFixedCapBaseHeap

func NewFixedCapBaseHeap[T constraints.Ordered](l int) FixedCapBaseHeap[T]

func NewFixedCapBaseHeapFromArray

func NewFixedCapBaseHeapFromArray[T constraints.Ordered](arr []T, less _interface.CompareFunc[T]) FixedCapBaseHeap[T]

type FixedCapMaxBaseHeap

type FixedCapMaxBaseHeap[T constraints.Ordered] []T

定容最大堆 可用于保留前n个最小元素

func NewFixedCapMaxBaseHeap

func NewFixedCapMaxBaseHeap[T constraints.Ordered](cap int) FixedCapMaxBaseHeap[T]

func NewFixedCapMaxBaseHeapFromArray

func NewFixedCapMaxBaseHeapFromArray[T constraints.Ordered](arr []T) FixedCapMaxBaseHeap[T]

func (FixedCapMaxBaseHeap[T]) Put

func (heap FixedCapMaxBaseHeap[T]) Put(val T)

type Heap

type Heap[T _interface.OrderKey[V], V constraints.Ordered] struct {
	// contains filtered or unexported fields
}

func NewHeap

func NewHeap[T _interface.OrderKey[V], V constraints.Ordered](l int, less _interface.CompareFunc[V]) *Heap[T, V]

func NewHeapFromArray

func NewHeapFromArray[T _interface.OrderKey[V], V constraints.Ordered](arr []T, less _interface.CompareFunc[V]) Heap[T, V]

func (*Heap[T, V]) First

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

func (*Heap[T, V]) Init

func (heap *Heap[T, V]) Init()

func (*Heap[T, V]) Last

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

func (*Heap[T, V]) Pop

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

func (*Heap[T, V]) Push

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

func (*Heap[T, V]) Remove

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

type MaxBaseHeap

type MaxBaseHeap[T constraints.Ordered] []T

func NewMaxBaseHeap

func NewMaxBaseHeap[T constraints.Ordered](l int) MaxBaseHeap[T]

func NewMaxBaseHeapFromArray

func NewMaxBaseHeapFromArray[T constraints.Ordered](arr []T) MaxBaseHeap[T]

func (MaxBaseHeap[T]) Init

func (h MaxBaseHeap[T]) Init()

func (*MaxBaseHeap[T]) Pop

func (h *MaxBaseHeap[T]) Pop() T

func (*MaxBaseHeap[T]) Push

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

func (*MaxBaseHeap[T]) Remove

func (h *MaxBaseHeap[T]) Remove(i int) T

type MaxHeap

type MaxHeap[T constraintsi.OrderKey[V], V constraints.Ordered] Heap[T, V]

func NewMaxHeap

func NewMaxHeap[T constraintsi.OrderKey[V], V constraints.Ordered](l int) MaxHeap[T, V]

func NewMaxHeapFromArray

func NewMaxHeapFromArray[T constraintsi.OrderKey[V], V constraints.Ordered](arr []T) MaxHeap[T, V]

func (*MaxHeap[T, V]) Init

func (h *MaxHeap[T, V]) Init()

func (*MaxHeap[T, V]) Pop

func (h *MaxHeap[T, V]) Pop() T

func (*MaxHeap[T, V]) Push

func (h *MaxHeap[T, V]) Push(x T)

func (*MaxHeap[T, V]) Remove

func (h *MaxHeap[T, V]) Remove(i int) T

Jump to

Keyboard shortcuts

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