utils

package
v0.0.0-...-8630f43 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsInt

func AbsInt(x int) int

func ExtractInts

func ExtractInts(s string) []int

func ExtractIntsSigned

func ExtractIntsSigned(s string) []int

func MaxInt

func MaxInt(nums ...int) int

func MinInt

func MinInt(nums ...int) int

func PowInt

func PowInt(base, exp int) int

Types

type Item

type Item[T any] struct {
	Value    T
	Priority int
	// contains filtered or unexported fields
}

type MaxHeap

type MaxHeap[T any] struct {
	PriorityQueue[T]
}

func NewMaxHeap

func NewMaxHeap[T any]() *MaxHeap[T]

func (*MaxHeap[T]) Less

func (mh *MaxHeap[T]) Less(i, j int) bool

type MinHeap

type MinHeap[T any] struct {
	PriorityQueue[T]
}

func NewMinHeap

func NewMinHeap[T any]() *MinHeap[T]

func (*MinHeap[T]) Less

func (mh *MinHeap[T]) Less(i, j int) bool

type PriorityQueue

type PriorityQueue[T any] []*Item[T]

func (PriorityQueue[T]) Len

func (pq PriorityQueue[T]) Len() int

func (*PriorityQueue[T]) Pop

func (pq *PriorityQueue[T]) Pop() any

func (*PriorityQueue[T]) Push

func (pq *PriorityQueue[T]) Push(x any)

func (PriorityQueue[T]) Swap

func (pq PriorityQueue[T]) Swap(i, j int)

type UnionFind

type UnionFind struct {
	Parents []int
	Sizes   []int
}

func NewUnionFind

func NewUnionFind(n int) *UnionFind

func (UnionFind) Count

func (uf UnionFind) Count() int

func (*UnionFind) FindParent

func (uf *UnionFind) FindParent(n int) int

func (*UnionFind) Union

func (uf *UnionFind) Union(a, b int)

Jump to

Keyboard shortcuts

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