Documentation
¶
Index ¶
- type Cell
- type Matrix
- func (m Matrix[T]) Adjacent(x, y int, wrap bool) []Cell[T]
- func (m Matrix[T]) Cartesian() bool
- func (m Matrix[T]) Clone() Matrix[T]
- func (m Matrix[T]) Col(x int) (col []T)
- func (m Matrix[T]) Equals(n Matrix[T]) bool
- func (m Matrix[T]) Fill(v T)
- func (m Matrix[T]) Fix(y int) int
- func (m Matrix[T]) Get(x, y int) T
- func (m Matrix[T]) Height() int
- func (m Matrix[T]) Row(y int) []T
- func (m Matrix[T]) Set(x, y int, v T)
- func (m Matrix[T]) Slice() []T
- func (m Matrix[T]) Submatrix(x, y, w, h int) Matrix[T]
- func (m Matrix[T]) Width() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Matrix ¶
type Matrix[T comparable] struct { // contains filtered or unexported fields }
A Matrix is a 2-dimensional table stored as a 1-dimensional slice
func FromSlice ¶ added in v0.0.6
func FromSlice[T comparable](cols int, cart bool, sl []T) (m Matrix[T], ok bool)
FromSlice creates a new matrix with the content of the input slice. It requires the matrix `width` (cols) and the type of matrix. If the length of the input slice is not a multiple of the width the `ok` return boolean will be false.
func New ¶
func New[T comparable](w, h int, cart bool) Matrix[T]
New creates a new Matrix given width, height and if it should use cartesian coordinates (0 at the bottom)
func NewLike ¶ added in v0.0.5
func NewLike[T comparable](m Matrix[T]) Matrix[T]
NewLike creates a new matrix with the same dimensions as the input matrix
func (Matrix[T]) Adjacent ¶ added in v0.0.4
Adjacent returns a list of Cell(s) adjacent to the one at x,y. If wrap is true coordinates that are outside the Matrix boundary will wrap around. For example if x=0 return add rightmost cell, if y=top add bottom cell.
func (Matrix[T]) Cartesian ¶ added in v0.0.5
Cartesian return true for cartesian coordinates (0 at the bottom) and false for computer coordinates (0 at the top)
func (Matrix[T]) Clone ¶ added in v0.0.2
Clone creates a new matrix that is a copy of the input matrix
func (Matrix[T]) Fill ¶ added in v0.0.3
func (m Matrix[T]) Fill(v T)
Fill sets all cells of the matrix to the specified value
func (Matrix[T]) Fix ¶
Fix converts the row number (y) from one coordinate system to the other (cartesian to computer or viceversa)
func (Matrix[T]) Slice ¶ added in v0.0.5
func (m Matrix[T]) Slice() []T
Slice return the backing slice for the Matrix