help

package
v0.0.0-...-10bb0ce Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2025 License: Unlicense Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dfs

func Dfs[T comparable](vertex T, adjacentFunc adjacent[T], validateFunc validate[T]) []T

func Djikstra

func Djikstra[T comparable](start T, goal T, distFunc dDistance[T], neighborFunc neighbors[T]) (map[T]int, map[T]T)

func DjikstraFull

func DjikstraFull[T comparable](start T, distFunc dDistance[T], neighborFunc neighbors[T]) (map[T]int, map[T]T)

func DjikstraPos

func DjikstraPos(start Pos, goal Pos, distFunc dDistance[Pos]) (map[Pos]int, map[Pos]Pos)

func DjikstraPosFull

func DjikstraPosFull(start Pos, goal Pos, distFunc dDistance[Pos]) (map[Pos]int, map[Pos]Pos)

func TaxiDist

func TaxiDist(p1 Pos, p2 Pos) int

Types

type Heap

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

Create Heaps such that cmp(parent, child) must be true

func NewHeap

func NewHeap[T comparable](comp func(a, b T) bool) *Heap[T]

func (*Heap[T]) Exists

func (h *Heap[T]) Exists(v T) bool

func (*Heap[T]) Len

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

func (*Heap[T]) Pop

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

Swap the root element to the end,

func (*Heap[T]) Push

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

Place an element at the end of the heap, then send it up until it is in a valid placement.

func (*Heap[T]) Visualize

func (h *Heap[T]) Visualize() (output string)

type Memoized

type Memoized[T comparable, V any] struct {
	// contains filtered or unexported fields
}

func Memoize

func Memoize[T comparable, V any](f func(T) V) *Memoized[T, V]

func (*Memoized[T, V]) Call

func (m *Memoized[T, V]) Call(x T) V

type Pos

type Pos struct {
	X, Y int
}

func AStar

func AStar(start Pos, goal Pos, h heuristic, d aDistance) []Pos

func Add

func Add(p1 Pos, p2 Pos) Pos

func (Pos) Down

func (p Pos) Down() Pos

func (Pos) Left

func (p Pos) Left() Pos

func (Pos) Neighbors

func (p Pos) Neighbors() []Pos

func (Pos) Right

func (p Pos) Right() Pos

func (Pos) Scale

func (p Pos) Scale(factor int) Pos

func (Pos) Up

func (p Pos) Up() Pos

func (Pos) Within

func (p Pos) Within(limit Pos) bool

type Queue

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

func NewQueue

func NewQueue[T any]() *Queue[T]

func (*Queue[T]) IsEmpty

func (q *Queue[T]) IsEmpty() bool

func (*Queue[T]) Pop

func (q *Queue[T]) Pop() T

func (*Queue[T]) Push

func (q *Queue[T]) Push(v T)

type Stack

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

func NewStack

func NewStack[T any]() *Stack[T]

func (*Stack[T]) IsEmpty

func (s *Stack[T]) IsEmpty() bool

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() T

func (*Stack[T]) Push

func (s *Stack[T]) Push(v T)

Jump to

Keyboard shortcuts

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