Documentation ¶
Index ¶
- func AdjustDownForBase[T any](heap []T, i int, less _interface.CompareFunc[T])
- func AdjustUpForBase[T any](heap []T, i int, less _interface.CompareFunc[T])
- func Down[T _interface.OrderKey[V], V constraints.Ordered](heap []T, i0, n int, less _interface.CompareFunc[V]) bool
- func DownForBase[T any](heap []T, i0, n int, less _interface.CompareFunc[T]) bool
- func Fix[T _interface.OrderKey[V], V constraints.Ordered](heap []T, i int, less _interface.CompareFunc[V])
- func FixForBase[T any](heap []T, i int, less _interface.CompareFunc[T])
- func HeapInit[T _interface.OrderKey[V], V constraints.Ordered](heap []T, less _interface.CompareFunc[V])
- func HeapInitForBase[T any](heap []T, less _interface.CompareFunc[T])
- func Up[T _interface.OrderKey[V], V constraints.Ordered](heap []T, j int, less _interface.CompareFunc[V])
- func UpForBase[T any](heap []T, j int, less _interface.CompareFunc[T])
- type BaseHeap
- type FixedCapBaseHeap
- type FixedCapMaxBaseHeap
- type Heap
- type MaxBaseHeap
- type MaxHeap
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]
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]
Click to show internal directories.
Click to hide internal directories.