grid

package
v0.0.0-...-6284559 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Directions4 = []aoc.Point{
	{X: 0, Y: 1},
	{X: 1, Y: 0},
	{X: 0, Y: -1},
	{X: -1, Y: 0},
}
View Source
var Directions8 = []aoc.Point{
	{X: 0, Y: 1},
	{X: 1, Y: 1},
	{X: 1, Y: 0},
	{X: 1, Y: -1},
	{X: 0, Y: -1},
	{X: -1, Y: -1},
	{X: -1, Y: 0},
	{X: -1, Y: 1},
}

Functions

This section is empty.

Types

type Grid

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

func New

func New[T any](xLen, yLen int64, movements []aoc.Point) *Grid[T]

func NewWithDefault

func NewWithDefault[T any](xLen, yLen int64, movements []aoc.Point, def T) *Grid[T]

func (*Grid[T]) Clone

func (g *Grid[T]) Clone() *Grid[T]

func (*Grid[T]) GetSliceInDirectionP

func (g *Grid[T]) GetSliceInDirectionP(p aoc.Point, direction aoc.Point, count int) []T

func (*Grid[T]) GetSliceToEdge

func (g *Grid[T]) GetSliceToEdge(x, y int64, movement aoc.Point) []T

func (*Grid[T]) GetState

func (g *Grid[T]) GetState(x, y int64) T

func (*Grid[T]) GetStateP

func (g *Grid[T]) GetStateP(p aoc.Point) T

func (*Grid[T]) IsValid

func (g *Grid[T]) IsValid(x, y int64) bool

func (*Grid[T]) IsValidPoint

func (g *Grid[T]) IsValidPoint(p aoc.Point) bool

func (*Grid[T]) Neighbours

func (g *Grid[T]) Neighbours(p aoc.Point) []aoc.Point

func (*Grid[T]) SetState

func (g *Grid[T]) SetState(x, y int64, state T)

func (*Grid[T]) SetStateP

func (g *Grid[T]) SetStateP(p aoc.Point, state T)

func (*Grid[T]) StateMap

func (g *Grid[T]) StateMap() map[aoc.Point]T

func (*Grid[T]) StateMapWhere

func (g *Grid[T]) StateMapWhere(f func(T) bool) map[aoc.Point]T

func (*Grid[T]) StateString

func (g *Grid[T]) StateString() string

func (*Grid[T]) StateStringInvertY

func (g *Grid[T]) StateStringInvertY() string

func (*Grid[T]) StatesWhere

func (g *Grid[T]) StatesWhere(f func(T) bool) []aoc.Point

func (*Grid[T]) XLen

func (g *Grid[T]) XLen() int64

func (*Grid[T]) YLen

func (g *Grid[T]) YLen() int64

type Vector

type Vector struct {
	Point     aoc.Point
	Direction aoc.Point
}

func (Vector) String

func (v Vector) String() string

Jump to

Keyboard shortcuts

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