grid

package
v0.0.0-...-a510a1c Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enum

func Enum[T constraints.Integer](opts ...rune) func(rune) (T, error)

Enum return a function suitable to pass to Read, that accepts any of opts and turns it into its position in that list.

Types

type Grid

type Grid[T any] struct {
	W int
	H int
	G []T
}

func New

func New[T any](w, h int) *Grid[T]

func Read

func Read[T any](r io.Reader, fromRune func(rune) (T, error)) (*Grid[T], error)

func (*Grid[T]) At

func (g *Grid[T]) At(p Pos) T

func (*Grid[T]) Bounds

func (g *Grid[T]) Bounds() Rectangle

func (*Grid[T]) Clone

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

func (*Grid[T]) Neigh4

func (g *Grid[T]) Neigh4(p Pos) []Pos

func (*Grid[T]) Pos

func (g *Grid[T]) Pos(i int) Pos

func (*Grid[T]) Set

func (g *Grid[T]) Set(p Pos, v T)

func (*Grid[T]) Valid

func (g *Grid[T]) Valid(p Pos) bool

type Pos

type Pos struct {
	Row int
	Col int
}

func (Pos) Add

func (p Pos) Add(δ Pos) Pos

func (Pos) Dist

func (p Pos) Dist(q Pos) int

func (Pos) Length

func (p Pos) Length() int

func (Pos) String

func (p Pos) String() string

func (Pos) Sub

func (p Pos) Sub(δ Pos) Pos

type Rectangle

type Rectangle struct {
	Min Pos
	Max Pos
}

func Rect

func Rect(rmin, cmin, rmax, cmax int) Rectangle

func (Rectangle) Add

func (r Rectangle) Add(p Pos) Rectangle

func (Rectangle) Canon

func (r Rectangle) Canon() Rectangle

func (Rectangle) Contains

func (r Rectangle) Contains(p Pos) bool

func (Rectangle) Empty

func (r Rectangle) Empty() bool

func (Rectangle) Eq

func (r Rectangle) Eq(s Rectangle) bool

func (Rectangle) Height

func (r Rectangle) Height() int

func (Rectangle) Hull

func (r Rectangle) Hull(s Rectangle) Rectangle

func (Rectangle) In

func (r Rectangle) In(s Rectangle) bool

func (Rectangle) Inset

func (r Rectangle) Inset(n int) Rectangle

func (Rectangle) Intersect

func (r Rectangle) Intersect(s Rectangle) Rectangle

func (Rectangle) Overlaps

func (r Rectangle) Overlaps(s Rectangle) bool

func (Rectangle) Width

func (r Rectangle) Width() int

Jump to

Keyboard shortcuts

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