Documentation ¶
Overview ¶
Package matrix 提供了一个简单的二维数组的实现
Index ¶
- type Matrix
- func (slf *Matrix[T]) FillFull(generateHandle func(x, y int) T)
- func (slf *Matrix[T]) FillFullWithPos(generateHandle func(pos int) T)
- func (slf *Matrix[T]) Get(x, y int) (value T)
- func (slf *Matrix[T]) GetExist(x, y int) (value T, exist bool)
- func (slf *Matrix[T]) GetHeight() int
- func (slf *Matrix[T]) GetMatrix() [][]T
- func (slf *Matrix[T]) GetMatrixWithPos() []T
- func (slf *Matrix[T]) GetWidth() int
- func (slf *Matrix[T]) GetWidth2Height() (width, height int)
- func (slf *Matrix[T]) GetWithPos(pos int) (value T)
- func (slf *Matrix[T]) Set(x, y int, data T)
- func (slf *Matrix[T]) SetWithPos(pos int, data T)
- func (slf *Matrix[T]) Swap(x1, y1, x2, y2 int)
- func (slf *Matrix[T]) SwapWithPos(pos1, pos2 int)
- func (slf *Matrix[T]) TrySwap(x1, y1, x2, y2 int, expressionHandle func(matrix *Matrix[T]) bool)
- func (slf *Matrix[T]) TrySwapWithPos(pos1, pos2 int, expressionHandle func(matrix *Matrix[T]) bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Matrix ¶
type Matrix[T any] struct { // contains filtered or unexported fields }
Matrix 二维矩阵
func (*Matrix[T]) FillFullWithPos ¶
FillFullWithPos 根据提供的生成器填充整个矩阵
func (*Matrix[T]) GetMatrix ¶
func (slf *Matrix[T]) GetMatrix() [][]T
GetMatrix 获取二维矩阵
- 通常建议使用 GetMatrixWithPos 进行处理这样将拥有更高的效率
func (*Matrix[T]) GetMatrixWithPos ¶
func (slf *Matrix[T]) GetMatrixWithPos() []T
GetMatrixWithPos 获取顺序的矩阵
func (*Matrix[T]) GetWidth2Height ¶
GetWidth2Height 获取二维矩阵的宽度和高度
func (*Matrix[T]) GetWithPos ¶
GetWithPos 获取特定坐标的内容
func (*Matrix[T]) SetWithPos ¶
SetWithPos 设置特定坐标的内容
func (*Matrix[T]) SwapWithPos ¶
SwapWithPos 交换两个位置的内容
Click to show internal directories.
Click to hide internal directories.