heapx

package
v1.1.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GreaterThanable

type GreaterThanable[T any] interface {
	GreaterThan(T) bool
}

type Heap

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

Heap is a generic heap implement based on container.heap

func NewMax

func NewMax[T constraints.Ordered](data ...T) *Heap[T]

New max heap

func NewMaxI

func NewMaxI[T GreaterThanable[T]](data ...T) *Heap[T]

New max heap with GreaterThanable

func NewMin

func NewMin[T constraints.Ordered](data ...T) *Heap[T]

New min heap

func NewMinI

func NewMinI[T LesserThanable[T]](data ...T) *Heap[T]

New min heap with LessThanable

func NewWith

func NewWith[T any](less func(T, T) bool, data ...T) *Heap[T]

New heap with custom less function heap top will be the "lessest" element

func (*Heap[T]) Data

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

func (*Heap[T]) Fix

func (h *Heap[T]) Fix(i int)

func (*Heap[T]) IsEmpty

func (h *Heap[T]) IsEmpty() bool

func (*Heap[T]) Len

func (h *Heap[T]) Len() int

func (*Heap[T]) Pop

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

func (*Heap[T]) Push

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

func (*Heap[T]) Remove

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

func (*Heap[T]) Snapshot

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

type LesserThanable

type LesserThanable[T any] interface {
	LesserThan(T) bool
}

Jump to

Keyboard shortcuts

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