geo

package
v0.0.0-...-3a05015 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Reduce

func Reduce[T comparable, V any, S Space[T]](s S, acc V, f ReduceFunc[T, V]) V

Types

type Dimension

type Dimension int
const (
	D1 Dimension = iota + 1
	D2
	D3
	D4
)

type FilterFunc

type FilterFunc[T comparable] func(p Point[T]) bool

type Location

type Location struct {
	A, B, C, D int
}

func LocSum

func LocSum(l, m Location) Location

func Neighbors

func Neighbors(l Location, m NeighborMode, d Dimension) []Location

type MapFunc

type MapFunc[T, V comparable] func(p Point[T]) Point[V]

type NeighborMode

type NeighborMode int
const (
	// Cardinal mode only targets direct North/South/East/West adjacent Locations
	NeighborModeCardinal NeighborMode = iota
	// Full mode includes Cardinal neighbors as well as diagonal ones
	NeighborModeFull
)

type Point

type Point[T any] struct {
	Loc Location
	Val T
}

type ReduceFunc

type ReduceFunc[T comparable, V any] func(p Point[T], r V) V

type Space

type Space[T comparable] interface {
	fmt.Stringer
	Set(l Location, v T)
	Get(l Location) T
	Size() int
	Iter() iter.Seq[Point[T]]
}

type Space1D

type Space1D[T comparable] map[int]Point[T]

func Filter1D

func Filter1D[T comparable](s Space1D[T], f FilterFunc[T]) Space1D[T]

func Map1D

func Map1D[T, V comparable](s Space1D[T], f MapFunc[T, V]) Space1D[V]

func (Space1D[T]) Get

func (s Space1D[T]) Get(l Location) T

func (Space1D[T]) Iter

func (s Space1D[T]) Iter() iter.Seq[Point[T]]

func (Space1D[T]) Set

func (s Space1D[T]) Set(l Location, v T)

func (Space1D[T]) Size

func (s Space1D[T]) Size() int

func (Space1D[T]) String

func (s Space1D[T]) String() string

type Space2D

type Space2D[T comparable] map[int]Space1D[T]

func Filter2D

func Filter2D[T comparable](s Space2D[T], f FilterFunc[T]) Space2D[T]

func Map2D

func Map2D[T, V comparable](s Space2D[T], f MapFunc[T, V]) Space2D[V]

func (Space2D[T]) Get

func (s Space2D[T]) Get(l Location) T

func (Space2D[T]) Iter

func (s Space2D[T]) Iter() iter.Seq[Point[T]]

func (Space2D[T]) Set

func (s Space2D[T]) Set(l Location, v T)

func (Space2D[T]) Size

func (s Space2D[T]) Size() int

func (Space2D[T]) String

func (s Space2D[T]) String() string

type Space3D

type Space3D[T comparable] map[int]Space2D[T]

func Filter3D

func Filter3D[T comparable](s Space3D[T], f FilterFunc[T]) Space3D[T]

func Map3D

func Map3D[T, V comparable](s Space3D[T], f MapFunc[T, V]) Space3D[V]

func (Space3D[T]) Get

func (s Space3D[T]) Get(l Location) T

func (Space3D[T]) Iter

func (s Space3D[T]) Iter() iter.Seq[Point[T]]

func (Space3D[T]) Set

func (s Space3D[T]) Set(l Location, v T)

func (Space3D[T]) Size

func (s Space3D[T]) Size() int

func (Space3D[T]) String

func (s Space3D[T]) String() string

TODO: implement Space3D.String()

type Space4D

type Space4D[T comparable] map[int]Space3D[T]

func Filter4D

func Filter4D[T comparable](s Space4D[T], f FilterFunc[T]) Space4D[T]

func Map4D

func Map4D[T, V comparable](s Space4D[T], f MapFunc[T, V]) Space4D[V]

func (Space4D[T]) Get

func (s Space4D[T]) Get(l Location) T

func (Space4D[T]) Iter

func (s Space4D[T]) Iter() iter.Seq[Point[T]]

func (Space4D[T]) Set

func (s Space4D[T]) Set(l Location, v T)

func (Space4D[T]) Size

func (s Space4D[T]) Size() int

func (Space4D[T]) String

func (s Space4D[T]) String() string

TODO: implement Space4D.String()

Jump to

Keyboard shortcuts

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