grid

package
v0.0.0-...-86a4e1d Latest Latest
Warning

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

Go to latest
Published: Apr 7, 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 Direction

type Direction byte
const (
	None Direction = iota
	North
	East
	South
	West
)

func DirectionFrom

func DirectionFrom(pos Position, from Position) Direction

type Grid

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

func New

func New[T any](size Size) *Grid[T]

func (*Grid[T]) Add

func (g *Grid[T]) Add(t T, r Rectangle) error

func (*Grid[T]) CanAddRectangle

func (g *Grid[T]) CanAddRectangle(r Rectangle) bool

func (*Grid[T]) ContainsPosition

func (g *Grid[T]) ContainsPosition(p Position) bool

func (*Grid[T]) DeleteAt

func (g *Grid[T]) DeleteAt(p Position)

func (*Grid[T]) ObjectAt

func (g *Grid[T]) ObjectAt(p Position) *Object[T]

func (*Grid[T]) Objects

func (g *Grid[T]) Objects() []*Object[T]

func (*Grid[T]) Size

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

type Object

type Object[T any] struct {
	Value T
	Rectangle
}

type Position

type Position struct {
	X, Y int
}

func P

func P(x, y int) Position

func (Position) Less

func (p Position) Less(q Position) bool

func (Position) Neighbours

func (p Position) Neighbours() []Position

func (Position) String

func (p Position) String() string

type Rectangle

type Rectangle struct {
	Position
	Size
}

func R

func R(p Position, s Size) Rectangle

func (Rectangle) Positions

func (r Rectangle) Positions() []Position

func (Rectangle) String

func (r Rectangle) String() string

type Size

type Size struct {
	DX, DY int
}

func S

func S(dx, dy int) Size

Jump to

Keyboard shortcuts

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