maps

package
v0.0.0-...-48003f5 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Up    = Direction{Y: -1}
	Right = Direction{X: 1}
	Down  = Direction{Y: 1}
	Left  = Direction{X: -1}

	North     = Up
	East      = Right
	South     = Down
	West      = Left
	NorthEast = Direction{Y: -1, X: 1}
	NorthWest = Direction{Y: -1, X: -1}
	SouthEast = Direction{Y: 1, X: 1}
	SouthWest = Direction{Y: 1, X: -1}
)

Functions

This section is empty.

Types

type Coordinate

type Coordinate struct {
	X int
	Y int
}

func CoordinateFromString

func CoordinateFromString(s string) Coordinate

func (Coordinate) Add

func (c Coordinate) Add(co Coordinate) Coordinate

func (Coordinate) Adjacent

func (c Coordinate) Adjacent() []Coordinate

func (Coordinate) Down

func (c Coordinate) Down() Coordinate

func (Coordinate) IsZero

func (c Coordinate) IsZero() bool

func (Coordinate) Left

func (c Coordinate) Left() Coordinate

func (Coordinate) ManhattanDistance

func (c Coordinate) ManhattanDistance(co Coordinate) int

func (Coordinate) Right

func (c Coordinate) Right() Coordinate

func (Coordinate) String

func (c Coordinate) String() string

func (Coordinate) Surrounding

func (c Coordinate) Surrounding() []Coordinate

func (Coordinate) Up

func (c Coordinate) Up() Coordinate

type Coordinate3D

type Coordinate3D struct {
	X int
	Y int
	Z int
}

func NewCoordinate3D

func NewCoordinate3D(s string) Coordinate3D

func (Coordinate3D) Add

func (Coordinate3D) Adjacent

func (c Coordinate3D) Adjacent() []Coordinate3D

func (Coordinate3D) ApplyRotation

func (c Coordinate3D) ApplyRotation(x, y, z int) Coordinate3D

func (Coordinate3D) Diff

func (Coordinate3D) ManhattanDistance

func (c Coordinate3D) ManhattanDistance(to Coordinate3D) int

func (Coordinate3D) String

func (c Coordinate3D) String() string

func (Coordinate3D) Sub

type CoordinateArray

type CoordinateArray struct {
	Coordinates []Coordinate

	Y int
	X int
}

func NewCoordinateArray

func NewCoordinateArray(coords []Coordinate) CoordinateArray

func (CoordinateArray) Coordinate

func (arr CoordinateArray) Coordinate(i int) Coordinate

func (CoordinateArray) Index

func (arr CoordinateArray) Index(c Coordinate) int

func (CoordinateArray) Size

func (arr CoordinateArray) Size() int

type Cuboid

type Cuboid struct {
	From Coordinate3D
	To   Coordinate3D
}

func (Cuboid) Contains

func (c Cuboid) Contains(co Cuboid) bool

func (Cuboid) Coordinates

func (c Cuboid) Coordinates() []Coordinate3D

func (Cuboid) IsOverlapping

func (c Cuboid) IsOverlapping(co Cuboid) bool

func (Cuboid) Overlapping

func (c Cuboid) Overlapping(co Cuboid) *Cuboid

func (Cuboid) Size

func (c Cuboid) Size() int

func (Cuboid) String

func (c Cuboid) String() string

func (Cuboid) Subdivide

func (c Cuboid) Subdivide(co Cuboid) ([]Cuboid, *Cuboid, []Cuboid)

type Direction

type Direction struct{ X, Y int }

func (Direction) Apply

func (d Direction) Apply(c Coordinate) Coordinate

func (Direction) Rotate

func (d Direction) Rotate(direction Direction) Direction

func (Direction) String

func (d Direction) String() string

type Item

type Item[T any] struct {
	Value    T
	Priority int
	Index    int
}

type Map

type Map[T any] struct {
	Columns int
	Rows    int
	Cells   [][]T
}

func MapFromCoordinates

func MapFromCoordinates[T any](coordinates map[Coordinate]T) Map[T]

func Merged

func Merged[T any](maps [][]Map[T]) Map[T]

func New

func New[T any](definition string, fn func(x, y int, b byte) T) Map[T]

func NewIntMap

func NewIntMap(definition string) Map[int]

func (Map[T]) Adjacent

func (m Map[T]) Adjacent(c Coordinate) []Coordinate

func (Map[T]) ArrPos

func (m Map[T]) ArrPos(c Coordinate) int

func (Map[T]) ArraySize

func (m Map[T]) ArraySize() int

func (Map[T]) At

func (m Map[T]) At(c Coordinate) T

func (Map[T]) Coordinates

func (m Map[T]) Coordinates() []Coordinate

func (Map[T]) CopyWith

func (m Map[T]) CopyWith(fn func(val T) T) Map[T]

func (Map[T]) Exists

func (m Map[T]) Exists(c Coordinate) bool

func (Map[T]) Length

func (m Map[T]) Length() int

func (*Map[T]) Set

func (m *Map[T]) Set(c Coordinate, val T)

func (Map[T]) String

func (m Map[T]) String() string

func (Map[T]) Stringf

func (m Map[T]) Stringf(sprintf func(c Coordinate, val T) string) string

func (Map[T]) Surrounding

func (m Map[T]) Surrounding(c Coordinate) []Coordinate

func (Map[T]) WithPadding

func (m Map[T]) WithPadding(n, e, s, w int) Map[T]

type PriorityQueue

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

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() interface{}

func (*PriorityQueue[T]) Push

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

func (PriorityQueue[T]) Swap

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

func (*PriorityQueue[T]) Update

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

type Rotation3D

type Rotation3D interface {
	Apply(c Coordinate3D) Coordinate3D
}

type RotationDirection

type RotationDirection struct {
	X bool
	Y bool
	Z bool
}

func (RotationDirection) Apply

type RotationFacing

type RotationFacing struct {
	X string
	Y string
	Z string

	Direction RotationDirection
}

func (RotationFacing) Apply

Jump to

Keyboard shortcuts

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