Documentation
¶
Overview ¶
Why the fuck is this not part of the language
Index ¶
- Variables
- func Contains[S ~[]E, E comparable](s S, e E) bool
- func Remove[S ~[]E, E comparable](s S, e E) S
- func RemoveAt[S ~[]E, E any](s S, i int) S
- type Coord
- type Direction
- type PQItem
- type PriorityQueue
- func (pq PriorityQueue[T]) IsEmpty() bool
- func (pq PriorityQueue[T]) Len() int
- func (pq PriorityQueue[T]) Less(i, j int) bool
- func (pq *PriorityQueue[T]) Pop() any
- func (pq *PriorityQueue[T]) PopItem() T
- func (pq *PriorityQueue[T]) Push(x any)
- func (pq *PriorityQueue[T]) PushItem(value T, priority int)
- func (pq PriorityQueue[T]) Swap(i, j int)
- type Queue
- type Set
Constants ¶
This section is empty.
Variables ¶
View Source
var DirFromOffset = map[Coord]Direction{ {X: -1, Y: 0}: UP, {X: 1, Y: 0}: DOWN, {X: 0, Y: -1}: LEFT, {X: 0, Y: 1}: RIGHT, }
View Source
var InverseDir = map[Direction]Direction{ UP: DOWN, DOWN: UP, LEFT: RIGHT, RIGHT: LEFT, }
View Source
var Offsets = map[Direction]Coord{
UP: {X: -1, Y: 0},
DOWN: {X: 1, Y: 0},
LEFT: {X: 0, Y: -1},
RIGHT: {X: 0, Y: 1},
}
Suposes (0,0) at top-left corner, with x going downwards and y going to the right
Functions ¶
func Contains ¶
func Contains[S ~[]E, E comparable](s S, e E) bool
func Remove ¶
func Remove[S ~[]E, E comparable](s S, e E) S
Types ¶
type PQItem ¶
type PQItem[T comparable] struct { Value T Priority int // contains filtered or unexported fields }
type PriorityQueue ¶
type PriorityQueue[T comparable] []*PQItem[T]
Uses container/heap for implementation Always pops the element with the lowest priority first
func NewPriorityQueue ¶
func NewPriorityQueue[T comparable]() *PriorityQueue[T]
func (PriorityQueue[T]) IsEmpty ¶
func (pq PriorityQueue[T]) IsEmpty() bool
func (PriorityQueue[T]) Len ¶
func (pq PriorityQueue[T]) Len() int
func (PriorityQueue[T]) Less ¶
func (pq PriorityQueue[T]) Less(i, j int) bool
func (*PriorityQueue[T]) Pop ¶
func (pq *PriorityQueue[T]) Pop() any
func (*PriorityQueue[T]) PopItem ¶
func (pq *PriorityQueue[T]) PopItem() T
func (*PriorityQueue[T]) Push ¶
func (pq *PriorityQueue[T]) Push(x any)
func (*PriorityQueue[T]) PushItem ¶
func (pq *PriorityQueue[T]) PushItem(value T, priority int)
func (PriorityQueue[T]) Swap ¶
func (pq PriorityQueue[T]) Swap(i, j int)
Click to show internal directories.
Click to hide internal directories.