matrix

package
v0.0.0-...-85a591d Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorOutRangeOfW x out of range of Width
	ErrorOutRangeOfW = errors.New("out of range of width")

	// ErrorOutRangeOfH y out of range of Height
	ErrorOutRangeOfH = errors.New("out of range of height")
)

Functions

func StateSliceMatched

func StateSliceMatched(ss1, ss2 []State) bool

Types

type IterateFunc

type IterateFunc func(int, int, State)

IterateFunc ...

type Matrix

type Matrix struct {
	// contains filtered or unexported fields
}

Matrix is a matrix data type width:3 height: 4 for [3][4]int

func New

func New(width, height int) *Matrix

New generate a matrix with map[][]bool

func (*Matrix) Copy

func (m *Matrix) Copy() *Matrix

Copy matrix into a new Matrix

func (*Matrix) Get

func (m *Matrix) Get(w, h int) (State, error)

Get state value from matrix with postion (x, y)

func (*Matrix) Height

func (m *Matrix) Height() int

Height ... height

func (*Matrix) Iterate

func (m *Matrix) Iterate(dir ScanDirection, f IterateFunc)

Iterate the Matrix with loop direction ROW major or COLUMN major

func (*Matrix) Print

func (m *Matrix) Print()

func (*Matrix) Set

func (m *Matrix) Set(w, h int, c State) error

Set [w][h] as true

func (*Matrix) Width

func (m *Matrix) Width() int

Width ... width

type ScanDirection

type ScanDirection uint

ScanDirection scan matrix driection

const (
	// ROW for row first
	ROW ScanDirection = 1

	// COLUMN for column first
	COLUMN ScanDirection = 2
)

type State

type State uint16

State value of matrix map[][]

const (
	// StateFalse 0xffff FALSE
	StateFalse State = 0xffff

	// ZERO 0x0 FALSE
	ZERO State = 0xeeee

	// StateTrue 0x0 TRUE
	StateTrue State = 0x0

	// StateInit 0x9999 use for initial state
	StateInit State = 0x9999

	// StateVersion 0x4444
	StateVersion State = 0x4444

	// StateFormat 0x7777 for persisted state
	StateFormat State = 0x7777

	// StateFinder 0x8000 to locate matrix and recognize it.
	StateFinder State = 0x8000
)

func XOR

func XOR(s1, s2 State) State

XOR ...

func (State) String

func (s State) String() string

Jump to

Keyboard shortcuts

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