types

package
v0.0.0-...-d5a05a3 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 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 Item

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

An Item is something we manage in a priority queue.

type Numeric

type Numeric interface {
	int | int8 | int16 | int32 | int64 |
		uint | uint8 | uint16 | uint32 | uint64 |
		float32 | float64
}

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

TODO: this is a pain with generics

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

func (pq *PriorityQueue[T]) PushNewItem(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 Queue

type Queue[T any] []*T

func (*Queue[T]) Push

func (queue *Queue[T]) Push(item *T)

func (*Queue[T]) Shift

func (queue *Queue[T]) Shift() *T

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)

type Vector

type Vector[T Numeric] struct {
	X, Y T
}

func NewVector

func NewVector[T Numeric](x, y T) Vector[T]

func (Vector[T]) Add

func (this Vector[T]) Add(vec Vector[T]) Vector[T]

func (*Vector[T]) AngleDegrees

func (this *Vector[T]) AngleDegrees() float64

func (*Vector[T]) AngleRadians

func (this *Vector[T]) AngleRadians() float64

func (Vector[T]) IsEqualTo

func (this Vector[T]) IsEqualTo(vec Vector[T]) bool

func (Vector[T]) Subtract

func (this Vector[T]) Subtract(vec Vector[T]) Vector[T]

func (*Vector[T]) ToString

func (this *Vector[T]) ToString() string

type Vector3d

type Vector3d struct {
	X, Y, Z int
}

func NewVector3d

func NewVector3d(x, y, z int) Vector3d

func (Vector3d) Add

func (this Vector3d) Add(vec Vector3d) Vector3d

func (*Vector3d) Divide

func (this *Vector3d) Divide(vec Vector3d) Vector3d

func (Vector3d) IsEqualTo

func (this Vector3d) IsEqualTo(vec Vector3d) bool

func (Vector3d) Length

func (this Vector3d) Length() float64

func (*Vector3d) LengthSquared

func (this *Vector3d) LengthSquared() int

func (*Vector3d) Multiply

func (this *Vector3d) Multiply(vec Vector3d) Vector3d

func (*Vector3d) Subtract

func (this *Vector3d) Subtract(vec Vector3d) Vector3d

func (*Vector3d) ToString

func (this *Vector3d) ToString() string

Jump to

Keyboard shortcuts

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