types

package
v0.0.0-...-8124729 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IntHeap

type IntHeap []int

An IntHeap is a min-heap of ints.

func (IntHeap) Len

func (h IntHeap) Len() int

func (IntHeap) Less

func (h IntHeap) Less(i, j int) bool

func (*IntHeap) Pop

func (h *IntHeap) Pop() any

func (*IntHeap) Push

func (h *IntHeap) Push(x any)

func (IntHeap) Swap

func (h IntHeap) Swap(i, j int)

type Item

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

An Item is something we manage in a priority queue.

type PriorityQueue

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

A PriorityQueue implements heap.Interface and holds Items.

func (*PriorityQueue[T]) Get

func (pq *PriorityQueue[T]) Get() *T

func (*PriorityQueue[T]) Init

func (pq *PriorityQueue[T]) Init()

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]) NewItem

func (pq *PriorityQueue[T]) NewItem(value *T, priority, index int)

sets index manually

func (*PriorityQueue[T]) Pop

func (pq *PriorityQueue[T]) Pop() interface{}

func (*PriorityQueue[T]) Push

func (pq *PriorityQueue[T]) Push(x interface{})

func (*PriorityQueue[T]) PushValue

func (pq *PriorityQueue[T]) PushValue(value *T, priority int)

sets index automatically

func (PriorityQueue[T]) Swap

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

func (*PriorityQueue[T]) Update

func (pq *PriorityQueue[T]) Update(value *T, priority int)

update modifies the priority and value of an Item in the queue.

type Set

type Set[T comparable] map[T]struct{}

func (*Set[T]) Add

func (set *Set[T]) Add(items ...T)

func (*Set[T]) Delete

func (set *Set[T]) Delete(item T)

func (*Set[T]) Has

func (set *Set[T]) Has(item T) bool

type Stack

type Stack[T any] []*T

func (*Stack[T]) Peek

func (stack *Stack[T]) Peek() (item *T)

func (*Stack[T]) Pop

func (stack *Stack[T]) Pop() (item *T)

func (*Stack[T]) Push

func (stack *Stack[T]) Push(item *T)

func (Stack[T]) String

func (stack Stack[T]) String() (out string)

type Vector3d

type Vector3d struct {
	X, Y, Z int
}

func NewVector3d

func NewVector3d(x, y, z int) Vector3d

func (Vector3d) Add

func (v Vector3d) Add(b Vector3d) Vector3d

func (*Vector3d) DistanceTo

func (v *Vector3d) DistanceTo(b Vector3d) float64

func (*Vector3d) Divide

func (v *Vector3d) Divide(b Vector3d) Vector3d

func (Vector3d) Length

func (v Vector3d) Length() float64

func (*Vector3d) LengthSquared

func (v *Vector3d) LengthSquared() int

func (*Vector3d) Multiply

func (v *Vector3d) Multiply(b Vector3d) Vector3d

func (*Vector3d) String

func (v *Vector3d) String() string

func (*Vector3d) Subtract

func (v *Vector3d) Subtract(b Vector3d) Vector3d

Jump to

Keyboard shortcuts

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